Add gitlab-runner in docker-swarm mode

How add gitlab runner to gitlab in swarm mode(fuck kubernetes).
Create docker-compose.yml

#docker stack deploy --compose-file=docker-compose.yml gitlab-runner
version: '3.3'
    image: gitlab/gitlab-runner:alpine-v10.6.0
    restart: always
      - /var/run/docker.sock:/var/run/docker.sock
      ###comment for first run
      #- ./configs/gitlab-runner:/etc/gitlab-runner
          - gitlab-runner
        #endpoint_mode: dnsrr
        #mode: replicated
        replicas: 1
          # Hard limit - Docker does not allow to allocate more
            cpus: '2'
            memory: 1200M
          # Soft limit - Docker makes best effort to return to it
            #cpus: '0.25'
            memory: 16M
        # service restart policy
          condition: on-failure
          delay: 5s
          max_attempts: 8
          window: 3s
        # service update configuration
          parallelism: 1
          delay: 10s
          failure_action: continue
          monitor: 60s
          max_failure_ratio: 0.3
        # placement constraint - in this case on 'worker' nodes only
          constraints: [node.role == manager]
    driver: overlay

Deploy to swarm

docker stack deploy --compose-file=docker-compose.yml gitlab-runner

Add runner to gitlab.
1. Obtain a token for a shared or specific Runner via GitLab’s interface

2. Register runner
To register a Runner using a Docker container:

Run the following command:

docker exec -it gitlab-runner gitlab-runner register

Enter your GitLab instance URL:

Please enter the gitlab-ci coordinator URL (e.g. )

Enter the token you obtained to register the Runner:

Please enter the gitlab-ci token for this runner

Enter a description for the Runner, you can change this later in GitLab’s UI:

Please enter the gitlab-ci description for this runner
[hostame] my-runner

Enter the tags associated with the Runner, you can change this later in GitLab’s UI:

Please enter the gitlab-ci tags for this runner (comma separated):

Choose whether the Runner should pick up jobs that do not have tags, you can change this later in GitLab’s UI (defaults to false):

Whether to run untagged jobs [true/false]:
[false]: true

Choose whether to lock the Runner to the current project, you can change this later in GitLab’s UI. Useful when the Runner is specific (defaults to true):

Whether to lock Runner to current project [true/false]:
[true]: true

Enter the Runner executor:

Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell:

If you chose Docker as your executor, you'll be asked for the default image to be used for projects that do not define one in .gitlab-ci.yml:

Please enter the Docker image (eg. ruby:2.1):

3. Save config persist

mkdir -p configs/gitlab-runner
cd configs/gitlab-runner
docker cp gitlab-runner_gitlab-runner.1.th8m8ajzsa1p3ynjjs9yzyioi:/etc/gitlab-runner/config.toml .

4. Unncomment line in docker-compose.yml

      - /var/run/docker.sock:/var/run/docker.sock
      ###comment for first run
      - ./configs/gitlab-runner:/etc/gitlab-runner

5. Change line in config config.toml

privileged = true

6. My gitlabrunner config.toml file as example

concurrent = 10
check_interval = 0
  name = "itc_runner"
  url = ""
  token = "878680df32323232322f248734e9"
  executor = "docker"
  limit = 0
  output_limit = 20000000000
    tls_verify = false
    image = "alpine:latest"
    privileged = true
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
    ##Для того чтобы не было Job's log exceeded limit of 4194304 bytes.
    output_limit = 2228192

I set custom dns serveer and increase running job at once to 10.

Добавить комментарий

Войти с помощью: 

Ваш e-mail не будет опубликован. Обязательные поля помечены *


Этот сайт использует Akismet для борьбы со спамом. Узнайте как обрабатываются ваши данные комментариев.