If you cannot find GitLab Runner on the first page, use the search bar or navigate through the library using the arrow buttons.
Deploy GitLab Runner on Scaleway Kubernetes clusters using Easy Deploy
GitLab Runner is a powerful tool that executes CI/CD jobs in GitLab. When hosted on Kubernetes, it leverages the scalability and resilience of container orchestration to efficiently manage and run your pipelines. By deploying GitLab Runner on a Kubernetes cluster, you can dynamically scale the number of runners based on demand, ensure high availability, and seamlessly integrate with your existing Kubernetes infrastructure. This setup enables you to optimize resource utilization, reduce overhead, and enhance the performance of your continuous integration and deployment processes.
Before you start
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- A valid API key
- Created a Scaleway Kubernetes Kapsule or Kosmos cluster
- A GitLab repository
Deploying the GitLab Runner application using Easy Deploy
-
In the Scaleway console, navigate to the Kubernetes section under Containers.
-
Click the name of the cluster where you wish to deploy GitLab Runner. The Cluster Information tab will display.
-
Click the Easy Deploy tab. The application dashboard displays.
-
Click Deploy Application. The application deployment wizard displays.
-
Choose Application Library to see the list of available applications.
-
Select the GitLab Runner application.
Tip -
Optionally, customize the default configuration for GitLab Runner using Helm Charts. If you do not need any customized configuration you can skip this step.
-
Provide the following GitLab details:
- GitLab URL (
gitlabUrl
): Go to your GitLab project, click Settings > CI/CD > Runners, and copy the GitLab Instance URL. - Registration Token (
runnerToken
): Under the Specific Runners section in Settings > CI/CD > Runners, copy the registration token for your project. These are necessary to allow GitLab Runner to register correctly with your GitLab project.
gitlabUrl: https://your-gitlab.comrunnerToken: "your-token"rbac:create: trueNoteThe information above is required to register your GitLab Runner with your GitLab project.
- GitLab URL (
-
Enter a name (e.g.
gitlab-runner
) and a Kubernetes namespace for your application. If you do not specify a name, GitLab Runner will be installed in the default namespace of the cluster. -
Click Deploy Application to deploy GitLab Runner on your Kubernetes cluster.
-
Use the following command to verify that the GitLab Runner is installed and running:
kubectl get pods -n <namespace> # replace "<namespace>" with the name of the Kubernetes namespace in which you have installed your GitLab Runner.You should see a pod with a name similar to
gitlab-runner-xxxxxx-xxxxx
in theRunning
state.
Configuring a GitLab CI/CD pipeline to use your Kubernetes Runner
If you do not have a GitLab repository yet, you can deploy a GitLab server using Easy Deploy on your Kubernetes cluster.
Register the GitLab Runner with GitLab
Before your GitLab Runner can start executing jobs from your GitLab repository, it needs to be registered with your GitLab server, as shown below:
-
Obtain the GitLab Runner Registration Token:
- Go to your GitLab project.
- Navigate to Settings > CI/CD > Runners.
- Under the Specific Runners section, you will see the registration token.
-
Register the GitLab Runner:
- Connect to your Kubernetes cluster where the GitLab Runner is deployed.
- Use the following command to start the registration process:
kubectl exec -it <gitlab-runner-pod-name> -- gitlab-runner register
- When prompted, enter the following details:
- GitLab instance URL: The URL of your GitLab server (e.g.,
https://gitlab.com
or your self-hosted GitLab URL). - Registration Token: The token you obtained in the previous step.
- Description: A description for this runner (e.g.,
k8s-runner
). - Tags: Tags for the runner (e.g.,
k8s-runner
). These tags should match the tags specified in your.gitlab-ci.yml
file. - Executor: Select
kubernetes
as the executor.
- GitLab instance URL: The URL of your GitLab server (e.g.,
Verify Runner registration
After registering the runner, verify that it is correctly registered and active:
- In your GitLab project, navigate to Settings > CI/CD > Runners.
- You should see your newly registered runner listed under the Specific Runners section.
Configure the GitLab CI/CD pipeline
-
Create/Edit the
.gitlab-ci.yml
file:- Ensure your
.gitlab-ci.yml
file includes jobs with tags that match your runner’s tags. Refer to the configuration example below to picture what your file should look like:
stages:- build- testbuild:stage: buildscript:- echo "Building the project..."- # Add your build steps heretags:- k8s-runnertest:stage: testscript:- echo "Running tests..."- # Add your test steps heretags:- k8s-runner - Ensure your
-
Push the configuration to GitLab:
- Push your
.gitlab-ci.yml
file to your GitLab repository:
git add .gitlab-ci.ymlgit commit -m "Add CI/CD pipeline configuration"git push origin main - Push your
Monitor the pipeline
Navigate to CI/CD > Pipelines in your GitLab project to view the status of your pipeline.
If the pipeline fails, you can check the logs of the GitLab Runner pod for more information:
kubectl logs -n <namespace> <gitlab-runner-pod-name>
Conclusion
You have successfully set up a GitLab Runner hosted on Kubernetes and configured your GitLab CI/CD pipeline to use it. This setup allows you to leverage the scalability and flexibility of Kubernetes for your CI/CD workflows.
For more detailed information on configuring your GitLab Runner, refer to the official GitLab documentation.