<p>I'm learning how to use Kubernetes and Gitlab CI/CD so I installed a Gitlab agent into my Kubernetes cluster by following <a href="https://docs.gitlab.com/ee/user/clusters/agent/install/" rel="nofollow noreferrer">the documentation</a>. I wrote a simple hello world pipeline to see if it works</p>
<pre><code>image: &quot;docker.io/ubuntu&quot;

stages:
  - build

build-contabo:
  stage: build
  script:
    - echo &quot;hello world&quot;
</code></pre>
<p>But the pipeline won't run and complains about missing configuration:</p>
<pre><code>Running with gitlab-runner 14.6.0 (5316d4ac)
  on vmi769777 NWjdRisx
Preparing the &quot;kubernetes&quot; 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
</code></pre>
<p>I read on how to <a href="https://docs.gitlab.com/ee/user/clusters/agent/repository.html" rel="nofollow noreferrer">configure an agent</a>, but could not find anything addressed this error.
I also deployed a <a href="https://github.com/skynet86/hello-world-k8s" rel="nofollow noreferrer">hello world</a> kubernetes deployment to check if my cluster does not work, but it ran successfully.</p>
<p>How can I provide configurations so that my pipeline runs?
And is this a problem with the Kubernetes Cluster or the Gitlab configuration?</p>

iaquobe
<p>I found the problem.</p>
<p>So <code>kubectl</code> works because when running it I am in the root user.
This user has a kubernetes config in its home <code>/home/root/.kube</code>.</p>
<p>The gitlab runner runs in a different user, in my case <code>gitlab-runner</code>.
This user doesn't have a kubernetes config dir.</p>
<p>Copying it from root solves the issue: <code>cp -r /home/root/.kube /home/gitlab-runner/.kube</code></p>
