Using Gitlab's generic K8s connection until Gitlab is added to v2.x Pipeline

The ability to use Gitlab in the v2.x Pipeline seems like a fairly common request. There’s a feature request under Ability to use GitLab in Pipeline #12608, so hopefully that will happen at some point. Until that fine day, what about the other way around? On Gitlab’s end there’s also an option for connecting GitLab with a Kubernetes cluster.

I’ve messed around with it a little bit, but keep getting 404s on the Gitlab end when trying to connect. It seems to be connecting to Rancher when I make a key in https://rancher.example.com/apikeys. I have a feeling I’m not using the right endpoint in API URL. It probably needs to come from the cluster or the project namespace rather than Global, but I’m not sure which to grab, and none I’ve tried yet have worked.

Anyone able to get this working and willing to help map the Rancher 2.0 UI to this info to Gitlab?

5 Likes

I would also be super interested to hear what other people are doing for this as well.

2 Likes

In will be useful to have both ways for connecting with GitLab, because:

GitLab’s integration with generic Kubernetes means it will use it as a target for it’s own CI, including Auto DevOps. (for CI you will use .gitlab-ci.yml)

Rancher’s integration with repositories means only that it’s Jenkins can connect with repository. (for CI configurations you will configure Jenkins)

I haven’t gotten very far with this yet. My use-case was to try to get Discourse into a pipeline. They (Discourse devs) recommend building the image in Ubuntu, then pushing. Unfortunately, deploying Ubuntu in the Gitlab pipeline with the Ubuntu Docker image limits the Docker storage driver to VFS, and AUFS or Overlay2 are needed for the Discourse build.

I’m considering adding Terraform to the mix (there’s a .gitlab-ci.yml for Terraform template in Gitlab, and a Deploying Discourse with Terraform example) to spin up a Digital Ocean Ubuntu droplet to do the build, then pushing the image back to Gitlab. But all of this is somewhat specific to Discourse so I haven’t been reporting details to this thread. That said, there does seem to be some interest in the general concept, and I hope others will add what they learn. I’ll report back if I get something working.

I’ve tried my best to get this working. Did someone else managed to get this working?

I also got this 404 message when I tried to install “Helm Tiller”. If I use the /v3 ending in the API URL, i get a new error however:

Something went wrong while installing Helm Tiller

Kubernetes error: failed to find schema api

The overall communication seems to work, since I get an authentication error when I use a wrong API key.

I am using GitLab 11.0.1-ee (b0260b1) and Rancher 2.0.2.

So this is not working yet?

I don’t have much to add here except that I’m seeing the same thing. I’m brand new to Rancher and just set up a 2.0.4 server, and I’m trying to integrate a project on my GitLab 10.8.4 server with it, and I get the same “Kubernetes error: failed to find schema api” error.

https://rancher.com/blog/2018/2018-08-07-cicd-pipeline-k8s-autodevops-rancher-and-gitlab/

I have tried your excellent description in: https://rancher.com/blog/2018/2018-08-07-cicd-pipeline-k8s-autodevops-rancher-and-gitlab/ but I still failed. During the installation of helm tiller I got the issue:
Something went wrong while installing Helm Tiller

  • Kubernetes error: 403 (Rancher Version 2.2, Gitlab Version 11.9.1). Is there might an improved method to the the integration done?

Please check if this comment helps: https://github.com/rancher/rancher/issues/19272#issuecomment-479011618

Thank you very much. I have tested your approach and it seams to work except that I get an issue with our cooperate proxy. Since gitlab creates the pods in the rancher cluster there is no way to add the proxy during deployment. I found a very nice way using Kubernetes PodPreset. Is there a way to enable PodPreset somehow. Can you please have a look into my second request: How set additional flags to the kubernetes cluster?

Curious about using the GitLab images are more basic and don’t have chef running in them:

Perhaps via this project:

Would be nice to have a more minimal / less complex gitlab setup.