Testing/CI/KubernetesRunners: Difference between revisions
No edit summary |
(Add rbac) |
||
Line 46: | Line 46: | ||
Create a <code>values.yaml</code> file for your runner configuration [https://docs.gitlab.com/runner/install/kubernetes.html#configuring-gitlab-runner-using-the-helm-chart] | Create a <code>values.yaml</code> file for your runner configuration [https://docs.gitlab.com/runner/install/kubernetes.html#configuring-gitlab-runner-using-the-helm-chart] | ||
like the snippet below. | like the snippet below. | ||
Enabling RBAC support [https://docs.gitlab.com/runner/install/kubernetes.html#enabling-rbac-support] | |||
seems to be needed [https://docs.gitlab.com/runner/install/kubernetes.html#error-job-failed-system-failure-secrets-is-forbidden] | |||
with the default AKS configuration. | |||
<code>nodeSelector</code> and <code>tolerations</code> are needed for the pods to run on the virtual nodes | <code>nodeSelector</code> and <code>tolerations</code> are needed for the pods to run on the virtual nodes | ||
Line 54: | Line 58: | ||
gitlabUrl: "https://gitlab.com/" | gitlabUrl: "https://gitlab.com/" | ||
runnerRegistrationToken: "" | runnerRegistrationToken: "" | ||
rbac: | |||
create: true | |||
runners: | runners: | ||
config: | | config: | |
Revision as of 15:16, 16 March 2023
To be able to run Gitlab CI jobs on a Kubernetes cluster, a Gitlab Runner must be installed [1].
Deployment
This sections documents the steps taken to deploy a GitLab Runner instance on a Azure Kubernetes cluster by using Helm [2].
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
Register the new runner [8].
Gitlab Runner
Now it's time to install the Gitlab runner with Helm [9].
Create a namespace:
kubectl create namespace "gitlab-runner"
Create a values.yaml
file for your runner configuration [10]
like the snippet below.
Enabling RBAC support [11] seems to be needed [12] with the default AKS configuration.
nodeSelector
and tolerations
are needed for the pods to run on the virtual nodes
[13]
[14].
gitlabUrl: "https://gitlab.com/" runnerRegistrationToken: "" rbac: create: true runners: config: | [[runners]] [runners.kubernetes] [runners.kubernetes.node_selector] "kubernetes.io/role" = "agent" "beta.kubernetes.io/os" = "linux" "type" = "virtual-kubelet" [runners.kubernetes.node_tolerations] "virtual-kubelet.io/provider" = "Exists"
Deploy the runner:
helm install --namespace gitlab-runner gitlab-runner -f values.yaml gitlab/gitlab-runner
If you change the configuration in values.yaml
, apply it with the upgrade command [15]:
helm upgrade --namespace gitlab-runner gitlab-runner -f values.yaml gitlab/gitlab-runner
Pause your runner before upgrading it to avoid service disruptions.