'ERROR: Preparation failed: getting Kubernetes config: invalid configuration: no configuration has been provided Gitlab
Hey guys this is blocking my flow! I have my gitlab runner installed on my Windows machine.
I registered a runner with a kubernetes executor. It previously used to work, but not any more.
I have a kubernetes cluster (the one provided by docker desktop) and the log of my jobs show this error:
ERROR: Preparation failed: getting Kubernetes config: invalid configuration: no configuration has been provided
I have checked a few other resources regarding this issue, such as: this gitlab runner issue , this other gitlab issue and this SO questions but no solution has worked.
The runner on my Runners setting is Running (Green)
The config.toml file looks correct:
concurrent = 5
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "kubernetes runner"
url = "https://gitlab.com/"
token = "My_Token"
executor = "kubernetes"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.kubernetes]
host = ""
bearer_token_overwrite_allowed = false
image = ""
namespace = ""
namespace_overwrite_allowed = ""
privileged = false
service_account_overwrite_allowed = ""
pod_annotations_overwrite_allowed = ""
[runners.kubernetes.affinity]
[runners.kubernetes.pod_security_context]
[runners.kubernetes.volumes]
[runners.kubernetes.dns_config]
and the config file is definitely in my home directory $HOME/.kube
I'm not sure how things work on windows, maybe the code is not able configured to find this path in windows? The thing is, it used to work before!
Also running:
kubectl get pods
returns results
Any one knows what might be the reason?
Solution 1:[1]
I had the same Problem.
What I found is that when you run kubectl you run it with root or some user.
For the gitlab-runner however there is a seperate user.
Running kubectl works because there is a Kubernetes config dir for this user /home/<kubectl-user>/.kube.
It doesn't work for your gitlab runner since there is no config dir for the user.
Copying /home/<kubectl-user>/.kube/ into /home/<gitlab-runner-user>/ should solve your issue
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | iaquobe |
