---
title: "Cloud server with GitLab Runner"
sidebar_label: "GitLab Runner"
sidebar_position: 3
toc_max_heading_level: 3
description: "How to create a cloud server for CI/CD automation"
---

import EditIcon from '@selectel/docux/icons/edit'
import CheckIcon from '@selectel/docux/icons/check'
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import {TabItemLabel} from '@selectel/docux/components'
import {CustomTable} from '@selectel/docux/components'
import Formbricks from '@theme/MDXComponents/Formbricks'
import CreateServer from '@site/i18n/en/docusaurus-plugin-content-docs/current/_partials/cloud-servers/applications/create-server-for-apps.mdx'

# Cloud server with GitLab Runner

GitLab Runner is open-source software used to automate and execute tasks (pipelines) in GitLab CI/CD. It acts as an agent that sequentially executes the steps defined in pipeline jobs. It allows you to automatically run application builds, tests, and deployments, and manage the entire CI/CD task execution process in GitLab.

You can [create a cloud server with a GitLab Runner application pre-installed](#create-cloud-server-with-gitlab-runner). 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](#add-runners). To run multiple CI/CD tasks, [enable concurrent job execution](#enable-simultaneous-jobs).

In Russia, the server runs on a pre-configured [SelectOS 1 64-bit](https://selectos.selectel.ru/news/mega/) operating system. In other [countries](/infrastructure/locations.mdx#country) — Ubuntu 22.04.

Before creating a cloud server with an application, review the [software license agreements](https://423.selcdn.ru/kb/license-agreements-for-application-images-LANG.pdf) included in the image.

## Minimum resource requirements \{#minimum-requirements}

<CustomTable>
  <table>
    <tbody>
      <tr>
        <th>vCPU count</th><td>2</td>
      </tr>

      <tr>
        <th>RAM</th><td>2 GB</td>
      </tr>

      <tr>
        <th>Boot volume</th><td>8 GB</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

## Create a cloud server with GitLab Runner \{#create-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, when creating a server, you need to create a private subnet and attach a public floating IP address. To set up GitLab Runner, you must specify the application parameters when creating the server.

1. Optional: [create a public floating IP address](#create-floating-ip).

2. [Create a cloud server with GitLab Runner](#create-gitlab-runner-server).

### 1. Optional: create a public floating IP address \{#create-floating-ip}

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](/cloud-servers/cloud-networks/public-floating-ip-addresses.mdx#create-public-floating-ip) section of the [Public Floating IP Addresses](/cloud-servers/cloud-networks/public-floating-ip-addresses.mdx) guide.

### 2. Create a cloud server with GitLab Runner \{#create-gitlab-runner-server}

<CreateServer AppNameInPanel="Cloud GitLab Runner" MinConfig="2 vCPU, RAM starting from 2 GB and a boot disk size starting from 8 GB" OptionalVolumes="In order to add additional" VolumeSize="Specify the size of the network disk in GB or TB">
  4. 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 obtain a token, use the instructions in [Create a project runner with a runner authentication token](https://docs.gitlab.com/ee/ci/runners/runners_scope.html#create-a-project-runner-with-a-runner-authentication-token) of the official GitLab documentation.

     4.3. Optional: specify a runner name for legacy registration; to do this, open the **Additional Application Parameters** block and in the **Runner Name** field enter it.

     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_limit` parameter in GitLab. Learn more in the [The \[\[runners\]\] section](https://docs.gitlab.com/runner/configuration/advanced-configuration/#the-runners-section) subsection of the [Advanced configuration](https://docs.gitlab.com/runner/configuration/advanced-configuration/) page of the GitLab documentation.

     4.5. Optional: specify runner tags; to do this, open the **Additional Application Parameters** block and enter them separated by commas in the **Runner Tags** field.
</CreateServer>

## Increasing the number of runners \{#add-runners}

1. [Connect to the cloud server](/cloud-servers/manage/connect-to-server.mdx).

2. Add the URL to the `/opt/gomplate/templates/gitlab-runner-env.tpl` file:

   ```bash
   echo 'export RUNNER_GITLAB_URL_2="https://<gitlab_server_url>"' >> /opt/gomplate/templates/gitlab-runner-env.tpl
   ```

   Specify `<gitlab_server_url>`: the URL of the GitLab server that GitLab Runner connects to.

3. If a second runner is being added for a different GitLab server, add the runner token to the `/opt/gomplate/templates/gitlab-runner-env.tpl` file:

   ```bash
   echo 'export RUNNER_REGISTRATION_TOKEN_2="<runner_token>"' >> /opt/gomplate/templates/gitlab-runner-env.tpl
   ```

   Specify `<runner_token>`: the registration token for GitLab Runner. You can obtain it using the [Create a project runner with a runner authentication token](https://docs.gitlab.com/ee/ci/runners/runners_scope.html#create-a-project-runner-with-a-runner-authentication-token) instructions in the official GitLab documentation.

4. Add the registration of the new runner to the `/opt/gitlab-runner-pre-flight.sh` script:

   * to the `register_runner:` function:

     ```bash
     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_runner:` function:

     ```bash
     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
     ```

5. Restart the service:

   ```bash
   sudo systemctl restart gitlab-runner
   ```

## Enabling parallel CI/CD job execution \{#enable-simultaneous-jobs}

:::warning

Parallel CI/CD job execution may reduce runner performance.

:::

1. [Connect to the cloud server](/cloud-servers/manage/connect-to-server.mdx).

2. In the `/etc/gitlab-runner/config.toml` file, specify the number of parallel jobs in the `concurrent`:

   ```bash
   sed -i '1 i\concurrent = 2' /etc/gitlab-runner/config.toml
   ```

<Formbricks />
