I needed a GitLab Runner for my GitLab server. I did not launch GitLab using Docker/Rancher, because I wanted to be able to do some things with it which might have been difficult to accomplish with GitLab running inside a container. I did attempt it but kept running into roadblocks. I am currently running GitLab 8.13, having just updated yesterday.
Created a folder on my EFS to hold the config settings
This will get mounted into my docker container.
Create Files And Folders for Catalog
Created proper directory structure in my Rancher-Catalog/templates folder.
Contents of my Config.yml
name: GitLab Runner description: GitLab Docker Runner for GitLab CE version: 1 category: Continuous Integration
Contents of My Docker-compose.yml
gl-multi-runner: labels: io.rancher.container.pull_image: always io.rancher.scheduler.affinity:host_label: name=rancherpool-pvt ## This makes sure that my container only runs on private Rancher instances. image: gitlab/gitlab-runner:latest ## You could pull this image, store it in your own registry if you want. Then pull it from there. privileged: true volumes: - /efs/data/gitlab-runner/config:/etc/gitlab-runner - /var/run/docker.sock:/var/run/docker.sock
Contents of my Rancher-compose.yml
.catalog: name: "GitLabRunner" version: "0" description: "GitLabRunner" uuid: "GitLabRunner-0" minumum_rancher_version: "v1.0" gl-multi-runner: scale: 1
Pushed Files To My Rancher Catalog
After refreshing my catalog in Rancher, I now see my GitLab Runner. I launched it.
Register My Runner with GitLab
You will need some information in order to register your new runner. Once you register it, the config file is saved to the mounted volume and can be used to create multiple identical runners.
In GitLab click on Admin and Runners. Make a note of your Registration Token.
Once I had the container running. I launched a shell session using the Rancher GUI and I ran this command:
This is what my session looked like:
gitlab-runner register Running in system-mode. Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/): https://myserver.mydomain.com/ Please enter the gitlab-ci token for this runner: mYreGistraTionTokEn Please enter the gitlab-ci description for this runner: [1227eaca85a8]: docker-runner Please enter the gitlab-ci tags for this runner (comma separated): docker Registering runner... succeeded runner=oRztgxRS Please enter the executor: parallels, virtualbox, kubernetes, docker-ssh, shell, ssh, docker+machine, docker-ssh+machine, docker: docker Please enter the default Docker image (eg. ruby:2.1): fstab/aws-cli Runner registered successfully. Feel free to start it, but if it's running alrea dy the config should be automatically reloaded!
Explanation Of The Items In Bold:
https://myserver.mydomain.com/ = Path to your gitlab server.
mYreGistraTionTokEn = Your Registration Token from GitLab
docker-runner = description you choose for this Runner. If it going to be a shell runner you might name is shell-runner.
docker = the tag for this runner. Any CI instructions that are tagged with “docker” will use this runner to process.
docker = Type of runner. In this case its a docker type of runner
fstab/aws–cli = The docker image I want to run my builds. I chose this one because I wanted the AWS CLI to be available during my builds.
After the changes were made I now see a file on my mapped drive called config.toml
Contents of config.toml
concurrent = 1 check_interval = 0 [[runners]] name = "docker-runner" url = "https://gitlab.panosoft.com/" token = "5351b527e85ea64e1da45da5234c3c" executor = "docker" [runners.docker] tls_verify = false image = "fstab/aws-cli" privileged = false disable_cache = false volumes = ["/cache"] [runners.cache]
I tested this with a simple tutorial I found here: https://about.gitlab.com/2016/08/26/ci-deployment-and-environments/ . Note that if you follow this tutorial, you will need to add the tag to your CI instructions:
tags: - docker