22. October 2020 4 min read
Setup gitlab runner in Kuberenets on Raspberry Pi with Helm
There is some preparation required for your Kubernetes cluster on Raspberry Pi to run gitlab-runner for your GitLab Continuous Integration pipeline. As official instructions also tell you, you will need to create a ServiceAccount. To make it easier lets put it into a yml file gitlab-admin-service-account.yaml with below content:
apiVersion: v1
kind: ServiceAccount
metadata:
name: gitlab
namespace: gitlab-managed-apps
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: gitlab
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: gitlab
namespace: gitlab-managed-apps
Now we need to apply this file, to create a gitlab user inside gitlab-managed-apps namespace:
kubectl apply -f gitlab-admin-service-account.yaml
Now we can start modifying the Official Gitlab Runner Helm Chart. First we need to change the image, as official image is not built for multiple arch, but there is a semi-official image provided by user klud called: klud/gitlab-runner:13.4.0. We also want to enable RBAC support and then we want to change in runner section also namespace to gitlab-managed-apps and most importantly we also need to modify the helper image to something arm based image: gitlab/gitlab-runner-helper:arm-${CI_RUNNER_REVISION}. This is to avoid such errors:
ERROR: Job failed (system failure): prepare environment: unable to upgrade connection: container not found ("helper"). Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information
After that its change of the ServiceAccount to previously created gitlab and that should be it. So changes in yml file are following:
image: klud/gitlab-runner:13.4.0
## ...
## For RBAC support:
rbac:
create: true
## ...
## Configuration for the Pods that that the runner launches for each new job
##
runners:
## ...
## Namespace to run Kubernetes jobs in (defaults to the same namespace of this release)
##
namespace: gitlab-managed-apps
## ...
## Helper Container specific configuration
##
helpers:
## ...
image: gitlab/gitlab-runner-helper:arm-${CI_RUNNER_REVISION}
## ...
## Service Account to be used for runners
##
serviceAccountName: gitlab
Do not forget to adjust the runnerRegistartionToken and gitlabUrl as well before executing a Helm command to apply the official chart with these changed values:
helm install --namespace gitlab-managed-apps -f gitlab-runner-deploy-values.yaml gitlab-runner gitlab/gitlab-runner
Now you can confirm running gitlab-runner pods and also try running some GitLab Pipelines to see if it works
kubectl get pods -A -o wide