Rancher and GitLab

Im trying to add rancher to gitlab ci/cd. I want to deploy gitlab runners dynamically into the k8s cluster and for that i have to add the cluster in the operations section which i believe its part of the auto devops system.

After following the rancher tutorial: https://rancher.com/blog/2019/connecting-gitlab-autodevops-authorized-cluster-endpoints/ i reached the point where it fails to install helm.
I followed the tutorial and the “install-helm” pod gives what i believe to be an api error:

  • helm init --tiller-tls --tiller-tls-verify --tls-ca-cert /data/helm/helm/config/ca.pem --tiller-tls-cert /data/helm/helm/config/cert.pem --tiller-tls-key /data/helm/helm/config/key.pem --service-account tiller

Creating /root/.helm
Creating /root/.helm/repository
Creating /root/.helm/repository/cache
Creating /root/.helm/repository/local
Creating /root/.helm/plugins
Creating /root/.helm/starters
Creating /root/.helm/cache/archive
Creating /root/.helm/repository/repositories.yaml
Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com
Adding local repo with URL:
$HELM_HOME has been configured at /root/.helm.
Error: error installing: Post Service Unavailable

I am using the cluster endpoint, tried with both a FQDN and without.

The rancher version is 2.3.2 and GitLab is running the latest version

1 Like

I’m also having trouble getting GitLab to use a Rancher cluster for CI/CD. Installing Tiller seems to work, but then it stalls on installing GitLab Runner.

Where are you seeing your errors? I’m using the GitLab web ui and the feedback is super minimal. I’d love to look at a log or something that can give me some useful information.

I had trouble when setting it up also. If you look at the screenshot below, there are 2 definitions for the cluster. If you use the first one (servers), it fails because for whatever reason, gitlab can’t handle subpaths as the location for the kubernetes api. If you use the second one (servers-ip-172-31-32-29), it fails becaue gitlab does not recognize the certificate of the IP address for whatever reason.

Screenshot from 2020-02-23 10-53-53

I was able to get it to work by deploying an nginx reverse proxy to proxy the first one. I proxied it through ingress and used letsencrypt to setup a valid certificate.

I created a git repo and helm chart (rancher 2 compatible) for this at the repo below. It works like a charm.

Make sure you specify the correct subpath.

Essentially, it’s removing the subpath because gitlab can’t handle a kubernetes api from a subpath for some silly reason.

I am trying to get this same integration working. However, I am using Rancher 2.4.8 and Gitlab 13.5.3. I did not install ingress since it already exists and is working. I installed the GitLab-Runner and I can see it in GitLab, but it does not show up anywhere in my Rancher kubernetes cluster. So that is the first mystery.

I do not want to use auto-devops. So I am trying to find some documentation on how to deploy apps using .gitlab-ci.yml and an application.yml file. Any help on this would be appreciated.

@cloudlady911 I just saw this. If you still need help setting it up, I could jump on a call and show you.

I am able to deploy apps just fine now. Thanks. I am not using the gitlab runners launched from GitLab, but rather using runners create with the gitlab spawner and docker-machine solutions.

1 Like

I ended up using the official gitlab helm release.


You can see my config here.