Search code examples
kubernetesgitlabopenstackgitlab-cikubectl

Gitlab CI on Kubernetes Cluster (Openstack)


I am trying to follow this short doc about how to use Gitlab CI with a Kubernetes Cluster that I am creating with Openstack: https://docs.gitlab.com/runner/install/kubernetes.html

I manage to create it but any time I create the ConfigMap and Deployment as specified in the previous link the pods it creates are stuck in a CrashLoopBackOff like this:

NAMESPACE     NAME                                            READY     STATUS             RESTARTS   AGE
gitlab        gitlab-runner-3998042981-f8dlh                  0/1       CrashLoopBackOff   36         2h
gitlab        gitlab-runner-3998042981-g9m5g                  0/1       CrashLoopBackOff   36         2h
gitlab        gitlab-runner-3998042981-q0bth                  0/1       CrashLoopBackOff   36         2h
gitlab        gitlab-runner-3998042981-rjztk                  0/1       CrashLoopBackOff   36         2h
kube-system   coredns-1977636023-1q47s                        1/1       Running            0          21h
kube-system   grafana-1173934969-vw49f                        1/1       Running            0          21h
kube-system   node-exporter-gitlab-ci-hc6k3ffax54o-minion-0   1/1       Running            0          21h
kube-system   node-exporter-gitlab-ci-hc6k3ffax54o-minion-1   1/1       Running            0          21h
kube-system   prometheus-873144915-s9m6j                      1/1       Running            0          21h

My problem is that I am not able to know why this happens since pod logs are not available when they are not created.

Apart from that I just do not know what to do with the specified volumes since I just think this has some relation with the crashloops.

Deployment specifies:

- configMap:
      name: gitlab-runner
    name: config
  - hostPath:
      path: /usr/share/ca-certificates/mozilla
    name: cacerts

I have found that:

A hostPath volume mounts a file or directory from the host node’s filesystem into your pod

After running the pods without the cacerts volume everything is created but afterwards no job will be executed.

Log from any pod:

Starting multi-runner from /etc/gitlab-runner/config.toml ...  builds=0
Running in system-mode.

Configuration loaded                                builds=0
Metrics server disabled
ERROR: Checking for jobs... forbidden               runner=<PARTOFTHETOKEN>
ERROR: Checking for jobs... forbidden               runner=<PARTOFTHETOKEN>
ERROR: Checking for jobs... forbidden               runner=<PARTOFTHETOKEN>
ERROR: Runner https://URL/ci<TOKEN> is not healthy and will be disabled!

Solution

  • Actual docs about having Gitlab CI running on a kubernetes cluster are not clear enough.

    You need to run somewhere gitlab-runner register with the token you get from the Runner's admin page of your Gitlab instance and grab another token from resulting config (cat /etc/gitlab-runner/config.toml | grep token) and paste it into your deployment config so it can now receive jobs from CI.

    UPDATE 2019: gitlab.com docs now make it clear: https://docs.gitlab.com/runner/register/#gnulinux