Testing/CI/KubernetesRunners: Difference between revisions
(Add section: Gitlab Runner) |
(Add intro) |
||
Line 1: | Line 1: | ||
To be able to run Gitlab CI jobs on a Kubernetes cluster, a Gitlab Runner must be installed [https://docs.gitlab.com/runner/install/]. | |||
This page documents the steps taken to deploy a GitLab Runner instance into an Azure Kubernetes cluster is by using Helm [https://docs.gitlab.com/runner/install/kubernetes.html]. | |||
== Connect a Kubernetes Cluster == | == Connect a Kubernetes Cluster == | ||
Revision as of 16:58, 15 March 2023
To be able to run Gitlab CI jobs on a Kubernetes cluster, a Gitlab Runner must be installed [1].
This page documents the steps taken to deploy a GitLab Runner instance into an Azure Kubernetes cluster is by using Helm [2].
Connect a Kubernetes Cluster
Kubernetes Cluster
Create a Kubernetes cluster on Azure (AKS). Single node pool "agentpool" for the Kubernetes system pods. Enable virtual nodes [3] to have on-demand capacity for the CI workloads.
CLI
Follow the docs to Install the Azure CLI.
Alternatively, run the Azure CLI in a container [4]:
podman run -it mcr.microsoft.com/azure-cli
Install the Kubernetes CLI (kubectl) [5]:
az aks install-cli
Install the Helm CLI [6]:
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
Sign in to Azure [7]:
az login
Connect to your Kubernetes Cluster. Open the Azure web dashboard for your cluster and push the "Connect" button. A list of commands will be displayed to connect to your cluster. Something like the following:
az account set --subscription ... az aks get-credentials ...
Gitlab Runner
Now it's time to install the Gitlab runner with Helm [8].
Gitlab
Follow the docs to Register the agent with GitLab.
Make sure you keep the command under "Recommended installation method" (last step).
Gitlab Agent
Now it's time to install the Gitlab agent with Helm [9]. Paste and run the command you got earlier from Gitlab. The "Recommended installation method".
The command you run should look like this:
helm repo add gitlab https://charts.gitlab.io helm repo update helm upgrade --install ...
Take note of the output of the helm upgrade --install
command. It contains the namespace where Helm installed the Gitlab agent.
Verify
You can check that the agent is running:
kubectl get pods -n <namespace>
The output of kubectl get pods
should list the gitlab-agent pod as running:
NAME READY STATUS RESTARTS AGE gitlab-agent-566c8b6898-hzk87 1/1 Running 0 0m30s
Now go back to your project on Gitlab. From the left sidebar, select Infrastructure > Kubernetes clusters. The agent should show up as connected.