Reputation: 737
I'm learning how to use Kubernetes and Gitlab CI/CD so I installed a Gitlab agent into my Kubernetes cluster by following the documentation. I wrote a simple hello world pipeline to see if it works
image: "docker.io/ubuntu"
stages:
- build
build-contabo:
stage: build
script:
- echo "hello world"
But the pipeline won't run and complains about missing configuration:
Running with gitlab-runner 14.6.0 (5316d4ac)
on vmi769777 NWjdRisx
Preparing the "kubernetes" executor 00:09
WARNING: Namespace is empty, therefore assuming 'default'.
Using Kubernetes namespace: default
ERROR: Preparation failed: getting Kubernetes config: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
I read on how to configure an agent, but could not find anything addressed this error. I also deployed a hello world kubernetes deployment to check if my cluster does not work, but it ran successfully.
How can I provide configurations so that my pipeline runs? And is this a problem with the Kubernetes Cluster or the Gitlab configuration?
Upvotes: 1
Views: 3647
Reputation: 737
I found the problem.
So kubectl
works because when running it I am in the root user.
This user has a kubernetes config in its home /home/root/.kube
.
The gitlab runner runs in a different user, in my case gitlab-runner
.
This user doesn't have a kubernetes config dir.
Copying it from root solves the issue: cp -r /home/root/.kube /home/gitlab-runner/.kube
Upvotes: 1
Reputation: 194
Have you tried setting KUBE_CONFIG_PATH? I was getting the same error, but export KUBE_CONFIG_PATH=/path/to/kubeconfig seems to fix the issue.
Upvotes: 1