Custom Thumbnail 

drop img here or browse to upload

add answer
create album
  • feeling
  • traveling
  • watching
  • playing
  • listening
  • Happy
  • Loved
  • Sad
  • Very sad
  • Angry
  • Confused
  • Hot
  • Broken
  • expressionless
  • Cool
  • Funny
  • Tired
  • Lovely
  • Blessed
  • Shocked
  • Sleepy
  • Pretty
  • Bored
0%

How to run a gitlab runner in your host machine

How to run a gitlab runner in your host machine

We are going to discus how we can run gitlab runner in ubuntu server machine. 

 

Download Package

curl -LJO "https://gitlab-runner-downloads.s3.amazonaws.com/latest/deb/gitlab-runner_amd64.deb"

dpkg -i gitlab-runner_amd64.deb

this will install the gitlab runner in your machine. 

 

Register a runner

We can register runner for individual repository also group runner. To create runner go to 

Settings > CI/CD > Runner 

there you will find Register the runner with this URL and registration token. Now lets create a runner which will execute by a docker - 

sudo -E gitlab-runner register
     Enter the GitLab instance URL (for example, https://gitlab.com/): https://gitlab.com/
     Enter the registration token: yourtoken
     Enter a description for the runner: My runner
     Enter tags for the runner (comma-separated): docker, node [your job tag]
     Enter an executor: docker-ssh, parallels, ssh, virtualbox, docker, shell, docker+machine, docker-ssh+machine, kubernetes, custom: docker

 

If you need further configuration follow the config file 

# nano  /etc/gitlab-runner/config.toml
concurrent = 10   #number of job at a time
check_interval = 0

[session_server]
  session_timeout = 1800
# first runner
[[runners]]
  name = "runner root"
  url = "https://gitlab.com/"
  token = "yourtoken"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "ruby:2.7"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0

# second runner
[[runners]]
  name = "Nise T4 Task Runner"
  url = "https://gitlab.com/"
  token = "yourtoken"
  executor = "shell"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "ruby:2.7"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0

 

Example docker runner full config 

[runners.docker]
  host = ""
  hostname = ""
  tls_cert_path = "/Users/ayufan/.boot2docker/certs"
  image = "ruby:2.7"
  memory = "128m"
  memory_swap = "256m"
  memory_reservation = "64m"
  oom_kill_disable = false
  cpuset_cpus = "0,1"
  cpus = "2"
  dns = ["8.8.8.8"]
  dns_search = [""]
  privileged = false
  userns_mode = "host"
  cap_add = ["NET_ADMIN"]
  cap_drop = ["DAC_OVERRIDE"]
  devices = ["/dev/net/tun"]
  disable_cache = false
  wait_for_services_timeout = 30
  cache_dir = ""
  volumes = ["/data", "/home/project/cache"]
  extra_hosts = ["other-host:127.0.0.1"]
  shm_size = 300000
  volumes_from = ["storage_container:ro"]
  links = ["mysql_container:mysql"]
  allowed_images = ["ruby:*", "python:*", "php:*"]
  allowed_services = ["postgres:9", "redis:*", "mysql:*"]
  [[runners.docker.services]]
    name = "registry.example.com/svc1"
    alias = "svc1"
    entrypoint = ["entrypoint.sh"]
    command = ["executable","param1","param2"]
  [[runners.docker.services]]
    name = "redis:2.8"
    alias = "cache"
  [[runners.docker.services]]
    name = "postgres:9"
    alias = "postgres-db"
  [runners.docker.sysctls]
    "net.ipv4.ip_forward" = "1"

 

If you want to run by shell please add the gitlab-user to docker group. 

usermod -aG docker gitlab-runner

 

Finally restart your gitlab-runner. 

sudo gitlab-runner restart

 

We finish all configuration. Now you will see a runner added to your gitlab runner.

 

Be the first person to like this
    Back
    friends & family