How to deploy from gitlab ci/cd via rancher?


we are running gitlab on prem. Currently we are evaluating the kubernetes integration. We are running kubernetes on prem using rancher. That means we have a rancher cluster where only rancher is running. Then we have a second “worker”-cluster which is managed by rancher. Both k8s-clusters are instances of rke2-kubernetes.

For that worker-cluster I created a standard user called gitlab within rancher which is shown as “cluster owner” in rancher.

Then I logged in to rancher as gitlab and took a look at the generated kubectl.
I took the certificate and token shown and used the url provided by rancher to register the cluster in gitlab. I’ve choosen that gitlab will be able to manage the cluster on gitlab integration page.
I also installed runners manually via helm chart.

Build jobs are running fine, but when I want to deploy apps to kubernetes the kubeclt image is throwing exceptions that I need to login first.

What do I need to do to be able to use gitlab? The issue seems to be that the created service account (by following the gitlab instructions) does not exist in rancher, so I cannot get behind the rancher-api/proxy.

I got it finally running by bypassing the rancher api and connect gitlab directly to the worker-cluster. But that’s not what I intended to do.

Any ideas or tutorials are very welcome.

Thanks in advance, Andreas