Building on the theme of recent posts, I was trying to deploy a dummy Spring Boot application and getting an error about the log format being an issue. I forgot we are running on ARM. Time to create a GitLab Runner.
Table of contents
Open Table of contents
Deployment does not start, it is all in the architecture
So today I learned that Docker images are architecture dependent, they have binaries added from the host system. I was using the shared Runners on GitLab, and looking thought the list, they are all AMD64. This presented an opportunity, could I start my own runner on my shiny new K8s cluster, to build my docker image, to run that on my shiny new k8s cluster?
Take the Helm
In the official docs, GitLab say to use their helm chart to install the runner and get it configured. So to the command line!
- Create a namespace to keep the runner in with
kubectl create ns gitlab-runner
, or use the GUI on Lens. - Add the Helm repo from GitLab with
helm repo add gitlab https://charts.gitlab.io
.
kubectl create ns gitlab-runner
helm repo add gitlab https://charts.gitlab.io
- Reconnect (I raised a bug on this) Lens to the cluster and head to the charts tab.
- Find the GitLab Runner chart, click it and click install to get the code window for the config.
- Add the following items to the config
gitlabUrl
this for me washttps://gitlab.com
rbac.create
set to true - I think I had this set to a map, but this took a lot of revisions (13) to find the right config and I seem to have lost the link to them.runnerToken
in the GitLab UI, in your project/group, go to the Settings -> CI/CD -> Runners section and click add runner, this will give you a token you need to add here.- The
runners.config
value was the hardest to get right. I used the below from various parts of the GitLab docs to get it working.
runners:
cache: {}
config: |
[[runners]]
[runners.kubernetes]
namespace = "{{.Release.Namespace}}"
image = "ubuntu:20.04"
privileged = true
[[runners.kubernetes.volumes.config_map]]
name = "docker-client-config"
mount_path = "/root/.docker/config.json"
sub_path = "config.json"
[[runners.kubernetes.volumes.empty_dir]]
name = "docker-certs"
mount_path = "/certs/client"
medium = "Memory"
[runners.kubernetes.node_selector]
"kubernetes.io/arch" = "arm64"
securityContext
This might not have been needed, I think you only need to add theprivileged
to the config, but I have not gone back to test it
securityContext:
allowPrivilegeEscalation: true
privileged: true
-
Click install and wait, but there is more.
-
To allow the runner to pull from
docker.io
to get its container images, you need to add an authentication token.- base64 encode your docker hub username and password
printf "USERNAME:PASSWORD" | openssl base64 -A
- I tried an auth token but that didn’t work. - add this to a config.yaml file for authentication to docker
{ auths: { https://index.docker.io/v1/: { auth: BASE_64_STRING } } }
- add the config map.
- base64 encode your docker hub username and password
printf "USERNAME:PASSWORD" | openssl base64 -A
kubectl create configmap docker-client-config --namespace gitlab_runner --from-file config.json
- it should look something like this:
apiVersion: v1
kind: ConfigMap
metadata:
name: docker-client-config
namespace: gitlab_runner
data:
config.json: "{
"auths\": {
t\"https://index.docker.io/v1/\": {\n\t\t\t\"auth\": \"BASE_64_STRING\"\n\t\t}\n\t}\n}"
- In the runner GUI I tagged this one as
arm64
, then we can tag jobs in the ci file as the same and they will run on our cluster!
Resources
https://github.com/nce/oci-free-cloud-k8s/blob/main/terraform/infra https://platform9.com/learn/v1.0/tutorials/traefik-ingress#step-2---expose-traefik-dashboard