Skip to main content

Command Palette

Search for a command to run...

Day 6: MicroK8s Integration with GitLab Runner using Helm

Updated
β€’2 min read
Day 6: MicroK8s Integration with GitLab Runner using Helm
M

Hey there! I'm currently working as an Associate DevOps Engineer, and I'm diving into popular DevOps tools like Azure Devops,Linux, Docker, Kubernetes,Terraform and Ansible. I'm also on the learning track with AWS certifications to amp up my cloud game. If you're into tech collaborations and exploring new horizons, let's connect!

πŸ“Œ This document is prepared with the help of official GitLab and Helm documentation.


βœ… Step 1: Install Helm

Install Helm using Snap:

snap install helm --classic

βœ… Step 2: Add the GitLab Helm Repository

helm repo add gitlab https://charts.gitlab.io

Update the repository:

helm repo update gitlab

βœ… Step 3: Check Available GitLab Runner Chart Versions

helm search repo -l gitlab/gitlab-runner

Sample output:

NAME                    CHART VERSION   APP VERSION     DESCRIPTION
gitlab/gitlab-runner    0.74.0          17.9.0          GitLab Runner
gitlab/gitlab-runner    0.73.3          17.8.3          GitLab Runner
gitlab/gitlab-runner    0.73.2          17.8.2          GitLab Runner
gitlab/gitlab-runner    0.73.1          17.8.1          GitLab Runner
gitlab/gitlab-runner    0.73.0          17.8.0          GitLab Runner
gitlab/gitlab-runner    0.72.1          17.7.1          GitLab Runner
gitlab/gitlab-runner    0.72.0          17.7.0          GitLab Runner

βœ… Step 4: Prepare the helm_values.yaml for Runner Configuration

Create a file named helm_values.yaml with the following content:

concurrent: 5
logFormat: json

rbac:
  create: true
  rules:
    - apiGroups: [""]
      resources: ["configmaps", "events", "pods", "pods/attach", "pods/exec", "secrets", "services"]
      verbs: ["get", "list", "watch", "create", "patch", "update", "delete"]

runners:
  config: |
    [[runners]]
      [runners.kubernetes]
        namespace = "{{.Release.Namespace}}"
        image = "alpine"

βœ… Step 5: Register the GitLab Runner

Go to GitLab Admin > Runners and get your GitLab URL and Registration Token.

Register the runner:

gitlab-runner register \
  --url https://<Your-GitLab-URL> \
  --token <Your-Token>

πŸ”Ž Note: Save the URL and token. You'll need them in the next step.


βœ… Step 6: Install the GitLab Runner using Helm

Apply the Helm chart with the following command:

microk8s.helm install \
  --namespace gitlab-runner \
  --create-namespace \
  --atomic \
  --timeout 120s \
  --set gitlabUrl=https://<Your-GitLab-URL> \
  --set runnerToken=<Your-Token> \
  --values helm_values.yaml \
  gitlab-runner gitlab/gitlab-runner \
  --version 0.74.0

βœ… Step 7: Verify the GitLab Runner Pod in MicroK8s

Check the deployed runner pod:

microk8s.kubectl get pod -n gitlab-runner

Sample Output:

NAME                             READY   STATUS    RESTARTS   AGE
gitlab-runner-7f957d884f-frb59   1/1     Running   0          5m51s

πŸŽ‰ GitLab Runner successfully integrated with MicroK8s!

Your GitLab Runner is now up and running, ready to execute your CI/CD pipelines within your MicroK8s Kubernetes cluster. βœ…

More from this blog

DevOps Journey with M Hassan

174 posts

I am writing these blogs because I recently completed a comprehensive DevOps course where I gained in-depth knowledge of the topics mentioned. As I progressed through the course, I realized the importance of having a concise and accessible resource to revise and reinforce my understanding of each topic. Therefore, I decided to create cheat sheets in the form of blog posts. These cheat sheets will not only serve as a handy reference for myself but also benefit others who are also interested in mastering DevOps concepts. By documenting each topic and providing concise explanations, I aim to create a valuable resource that simplifies complex concepts and facilitates hands-on practice. This way, I can solidify my own understanding while helping others on their DevOps journey.