# Day 6: MicroK8s Integration with GitLab Runner using Helm

> 📌 *This document is prepared with the help of official GitLab and Helm documentation.*

---

### ✅ **Step 1: Install Helm**

Install Helm using Snap:

```plaintext
snap install helm --classic
```

---

### ✅ **Step 2: Add the GitLab Helm Repository**

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

Update the repository:

```plaintext
helm repo update gitlab
```

---

### ✅ **Step 3: Check Available GitLab Runner Chart Versions**

```plaintext
helm search repo -l gitlab/gitlab-runner
```

**Sample output:**

```plaintext
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:

```plaintext
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 &gt; Runners** and get your **GitLab URL** and **Registration Token**.

Register the runner:

```plaintext
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:

```plaintext
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:

```plaintext
microk8s.kubectl get pod -n gitlab-runner
```

**Sample Output:**

```plaintext
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. ✅
