Running GitLab Runner on Kubernetes is an efficient way to leverage the scalability and flexibility of Kubernetes while managing your CI/CD pipelines. Here's a guide to help you set up GitLab Runner on a Kubernetes cluster.
- Kubernetes Cluster: Ensure you have a running Kubernetes cluster. You can use managed Kubernetes services like GKE, EKS, or AKS, or set up your own using tools like Minikube.
- kubectl: Kubernetes command-line tool to interact with your cluster.
- Helm: Package manager for Kubernetes.
- GitLab Account: Access to your GitLab instance (either self-hosted or GitLab.com).
The following repo contains the values.yaml. We will use this file to provide custom values to the Helm chart.
If you haven't installed Helm, you can do so by following the official installation guide here.
Add the GitLab repository to Helm:
helm repo add gitlab https://charts.gitlab.io/
helm repo updateIt's a good practice to create a separate namespace for GitLab Runner:
kubectl create namespace gitlab-runnerTo register a new GitLab Runner, follow these steps:
For GitLab.com:
- Go to your project or group in GitLab.
- Navigate to Settings > CI / CD.
- Expand the Runners section.
- Click on Register an instance runner/New group runner.
- Enter the Tags and other details. Leave the fields blank to use the default.
- Copy the registration token provided.
For Self-hosted GitLab:
- Log in to your GitLab instance.
- Go to the desired project or group.
- Navigate to Settings > CI / CD.
- Expand the Runners section.
- Click on Register a Runner.
- Enter the Tags and other details. Leave the fields blank to use the default.
- Copy the registration token provided.
Note - The code should begin with "glrt-"
Update Tags and the service account name in the values.yaml file.
You can install the GitLab Runner Helm chart with the following command:
helm install --namespace gitlab-runner gitlab-runner -f values.yaml gitlab/gitlab-runnerReplace values.yaml with your custom configuration file. Refer to this documentation for more details.
Running GitLab Runner on Kubernetes provides a scalable and flexible CI/CD environment that can handle large workloads efficiently. By using Helm, you can easily manage the deployment and configuration of GitLab Runner, ensuring that your pipelines run smoothly.