This document helps teach you how to connect your IBM Kubernetes cluster to a Hosted Gitlab instance so you can leverage your own infrastructure for continuous integration and continuous deployment.
Most of this document is influenced from the official documentation from Gitlab.
- A Kubernetes cluster on the IBM cloud
- An IP that the your Gitlab instance can reach
- ibmcloud CLI installed and configured
- Authenticate with the IBM cloud CLI so you can connect to your Kubernetes cluster.
ibmcloud login # with --sso if you need to use single sign on ibmcloud cs region-set us-south # The region you have your cluster in ibmcloud cs cluster-config YOURCLUSTERNAME # you will need to run the export KUBECONFIG command kubectl get nodes # a sanity check to make sure you can authenticate with your Kubernetes cluster
- Create a directory to do some work inside of it, and save some files if needed.
mkdir gitlab-runner cd gitlab-runner
- Add the
helmrepo from gitlab.
helm repo add gitlab https://charts.gitlab.io
helmon both your local machine and in your Kubernetes cluster.
- Create a
values.yamlfor your configuration of gitlab-runner, the full values.yml is here.
wget https://gitlab.com/charts/gitlab-runner/raw/master/values.yaml vi values.yaml
- The only two settings you have to edit in the
values.yamlare the following:
gitlabUrl- the GitLab Server URL (with protocol) to register the runner against
runnerRegistrationToken- The Registration Token for adding new Runners to the GitLab Server. This must be retrieved from your GitLab Instance. See the GitLab Runner Documentation for more information.
- After the configuration is complete, run the following command with a NAMESPACE that won’t step on another project. Using something like
gitlab-runnersas the namespace will isolate the pods in your Kubernetes cluster.
helm install --namespace NAMESPACE --name gitlab-runner -f values.yaml gitlab/gitlab-runner
- You should now be able to see your runner in the
admin/runnersURL on your Gitlab instance.
To uninstall the GitLab Runner Chart, run the following:
helm delete --namespace NAMESPACE RELEASE-NAME