Cloud server with GitLab Runner
GitLab Runner is open-source software used to automate and execute tasks (pipelines) in GitLab CI/CD. It operates as an agent that sequentially executes steps defined in pipeline jobs. It allows you to automate application building, testing, and deployment, and manage the entire CI/CD task execution process in GitLab.
You can create a cloud server with a pre-installed GitLab Runner application. The application runs inside a Docker container on the cloud server.
If you need to run multiple runners in a single Docker container, increase the number of runners. To run multiple CI/CD jobs, enable parallel job execution.
In Russia, the server runs with a configured SelectOS 1 64-bit operating system. In other countries — Ubuntu 22.04.
Before creating a cloud server with the application, read the software license agreements for the software included in the image.
Minimum resource requirements
Create a cloud server with GitLab Runner
To use GitLab Runner with a GitLab server from a different network, the cloud server with GitLab Runner must be accessible from the internet. To do this, create a private subnet and attach a public floating IP address when creating the server. To configure GitLab Runner, you must specify the application parameters when creating the server.
1. Optional: create a public floating IP address
Create a public floating IP address to ensure the cloud server with GitLab Runner is accessible from the internet.
Use the Create a public floating IP address section of the Public floating IP addresses manual.
2. Create a cloud server with GitLab Runner
-
In the control panel, in the top menu, click Products and select Cloud Servers.
-
Click Create Server.
-
Fill in the blocks:
-
Check the cloud server price.
-
Click Create.
Name and location
-
Enter the server name. It will be set as the hostname in the operating system.
-
Select the location where the server will be created. The list of available server configurations and resource cost depend on the location. You cannot change the location after creating the server.
Source
-
Open the Applications tab.
-
Select Cloud GitLab Runner.
-
Optional: if you need a different current or archived application version, in the Version field, select the desired version.
-
Fill in the application parameters:
4.1. Enter the URL of the GitLab server to which the GitLab Runner will be connected.
4.2. Enter the runner registration token. To get a token, refer to the Create a project runner with a runner authentication token guide in the official GitLab documentation.
4.3. Optional: specify a runner name for legacy registration. To do this, open the Additional application parameters block and enter it in the Runner name field.
4.4. Optional: specify the maximum build log size in kilobytes. To do this, open the Additional application parameters block and enter the value in the Build log size limit (KB) field. The setting in this field corresponds to the
output_limitparameter in GitLab. For more information, see the The [[runners]] section subsection in the Advanced configuration guide of the GitLab documentation.4.5. Optional: specify runner tags. To do this, open the Additional application parameters block and enter them in the Runner tags field separated by commas.
Configuration
Select a configuration from 2 vCPUs, RAM from 2 GB, and a boot disk size from 8 GB. For all lines except Shared and Dedicated, two types of server configurations are available:
- fixed configurations — configurations of lines with different technical specifications, in which the ratio of resources is fixed;
- custom configurations — configurations in which you can specify any ratio of resources.
Configurations use different processors depending on the line and pool segment. You can customize the selected configuration. After creating the server, you will be able to change the configuration.
Fixed configuration
Custom configuration
-
Open the tab with the line.
-
Click Fixed.
-
Optional: you can customize the configuration if you are creating a server in the ru-6 multi-AZ pool segment or pool segments ru-3b, ru-7a, and ru-7b:
3.1. Expand the block with the configuration settings description.
3.2. Optional: select a processor manufacturer. Selecting a manufacturer is not available in all pools.
3.3. Optional: if you do not want physical processor cores to be assigned to the cloud server vCPUs, uncheck the Dedicated cores checkbox. For more information, see the Dedicated Cores instructions.
3.4. Optional: if you want to disable Hyper-Threading for a server with dedicated cores, uncheck the Hyper-Threading (SMT) checkbox.
3.5. Optional: if you are creating a server with dedicated cores and want to place a multi-processor server on a single NUMA node, check the Mandatory placement on a single NUMA node checkbox. A server with 4 vCPUs or more can be placed on a single NUMA node. If the cloud server resources cannot be placed on a single node, it will not be created. For more information, see the Placement on a Single NUMA Node section of the Dedicated Cores instructions.
-
Select a configuration.
-
If both local and network disks are available in the selected configuration, select the disk to be used as the boot disk:
- local disk — check the Local SSD NVMe disk checkbox. A server with a local disk can only be created from images and applications;
- network disk — do not check the Local SSD NVMe disk checkbox.
The amount of RAM allocated to the server may be less than specified in the configuration — the operating system kernel reserves part of the RAM depending on the kernel version and distribution. You can check the allocated amount on the server using the
sudo dmesg | grep Memorycommand.
Disks
-
If you did not check the Local SSD NVMe disk checkbox when customizing the configuration, the first specified network disk will be used as the server boot disk. To configure it:
1.1. Select the boot network disk type.
1.2. Specify the network boot disk size in GB or TB. Take into account the network disk limits on maximum size.
1.3. If you selected the Universal v2 or Fast SSD v2 disk type, specify the total number of read and write operations in IOPS. After creating the disk, you can change the number of IOPS — decrease or increase it. The number of IOPS changes is unlimited.
-
To add an additional network disk of the server :
2.1. Click Add.
2.2. Select the network disk type.
2.3. Specify the network disk size in GB or TB. Take into account the network disk limits on maximum size.
2.4. If you selected the Universal v2 or Fast SSD v2 disk type, specify the total number of read and write operations in IOPS. After creating the disk, you can change the number of IOPS — decrease or increase it. The number of IOPS changes is unlimited.
After creating the server, you will be able to attach new additional disks.
Internet
Configure public access to the server.
The cloud server will be added to the private subnet connected to the cloud router with 1:1 NAT and internet access. Internet access to and from the internet will be carried out via the cloud router. The server will be accessible from the internet via a public floating IP address.
-
In the Connecting from the internet field, select the Public floating IP address access type.
-
Select the public floating IP address you created in Step 1.
Private network
A cloud server can be added to an existing or new private subnet.
Existing private subnet
New private subnet
-
In the Subnet field, select a private subnet.
-
Optional: in the IP address field, change the default IP address.
-
In the Router field, select an existing router or create a new one.
If the router is not connected to the internet, it will be automatically connected to the internet after the server is created.
Security
Select security groups to filter traffic on server ports. Without security groups, traffic will be blocked. If the block is missing, traffic filtering (port security) is disabled in the server network. With traffic filtering disabled, all traffic will be allowed.
Access
-
Place a project SSH key on the server for secure connection:
1.1. If the project SSH key has not been added to the cloud platform, click Add SSH key, enter the key name, paste the public key in OpenSSH format, and click Add.
1.2. If the project SSH key has been added to the cloud platform, in the SSH key field, select the existing key. The SSH key is only available in the pool where it is placed.
-
Optional: in the Password for "root" field:
2.1. Copy the password of the
rootuser — a user with unrestricted permissions for all actions on the system.2.2. Save the password in a safe place and do not share it in plain text.
Additional settings
-
Optional: if you plan to create multiple servers and want to increase infrastructure fault tolerance, add the server to a placement group:
1.1. To create a new group, in the Placement group field, click Create.
1.2. Select New group and enter the group name.
1.3. Select a placement policy on different hosts:
- desirable — soft-anti-affinity. The system will try to place the servers on different hosts. If there is no suitable host when creating the server, it will be created on the same host;
- mandatory — anti-affinity. Servers in the group must be located on different hosts. If there is no suitable host when creating the server, the server will not be created.
1.4. If the group has been created, in the Placement group field, select the placement group.
-
Optional: to add additional information or filter servers in the list, add server tags. Operating system and configuration tags are added automatically. To add a new tag, in the Tags field, enter the tag.
-
To add a script that will be executed using the cloud-init agent on the first boot of the operating system, in the Automation block, in the User data field:
- open the Text tab and paste the script as text;
- or open the File tab and upload the file with the script.
Increasing the number of runners
-
In the
/opt/gomplate/templates/gitlab-runner-env.tplfile, add the URL:echo 'export RUNNER_GITLAB_URL_2="https://<gitlab_server_url>"' >> /opt/gomplate/templates/gitlab-runner-env.tplSpecify
<gitlab_server_url>— the URL of the server with GitLab that GitLab Runner connects to. -
If the second runner is added for another GitLab server, add the runner token to the
/opt/gomplate/templates/gitlab-runner-env.tplfile:echo 'export RUNNER_REGISTRATION_TOKEN_2="<runner_token>"' >> /opt/gomplate/templates/gitlab-runner-env.tplSpecify
<runner_token>— the registration token for GitLab Runner. You can obtain it following the Create a project runner with a runner authentication token instructions in the official GitLab documentation. -
In the
/opt/gitlab-runner-pre-flight.shscript, add the registration of the new runner:-
to the
register_runnerfunction:sed -i '/register_runner () {/,/^}/ {/^}/ i\echo "Register additional runner"\docker run -i --rm \\\-v /etc/gitlab-runner:/etc/gitlab-runner \\\gitlab/gitlab-runner:ubuntu-v17.5.4 register \\\--non-interactive \\\--url "\${RUNNER_GITLAB_URL_2}" \\\--token "\${RUNNER_REGISTRATION_TOKEN_2}" \\\--template-config /etc/gitlab-runner/config-template.toml \\\--executor "docker" \\\\${RUNNER_ADDITIONAL_PARAMS}}' /opt/gitlab-runner-pre-flight.sh -
to the
register_legacy_runnerfunction:sed -i '/register_legacy_runner () {/,/^}/ {/^}/ i\echo "Register additional runner"\docker run -i --rm \\\-v /etc/gitlab-runner:/etc/gitlab-runner \\\gitlab/gitlab-runner:ubuntu-v17.5.4 register \\\--non-interactive \\\--url "\${RUNNER_GITLAB_URL_2}" \\\--registration-token "\${RUNNER_REGISTRATION_TOKEN_2}" \\\--template-config /etc/gitlab-runner/config-template.toml \\\--executor "docker" \\\\${RUNNER_ADDITIONAL_PARAMS}}' /opt/gitlab-runner-pre-flight.sh
-
-
Restart the service:
sudo systemctl restart gitlab-runner
Enabling parallel CI/CD job execution
Parallel CI/CD job execution may reduce runner performance.
-
In the
/etc/gitlab-runner/config.tomlfile, specify the number of parallel jobs in theconcurrentparameter:sed -i '1 i\concurrent = 2' /etc/gitlab-runner/config.toml