<p>I use gitlab for my CI, they host it and i have my own runners.
I have a k8s cluster running in gke.</p>

<p>I want to use <code>kubectl apply</code> to deploy new versions of my containers.</p>

<p>This all works from my local machine because it uses my google account.</p>

<p>I tried setting this all up as suggested by k8s and gitlab
1. copy over the <code>ca.crt</code>
2. copy over the token</p>

<pre><code>- echo "$KUBE_CA_PEM" &gt; kube_ca.pem
- kubectl config set-cluster default-cluster --server=$KUBE_URL --certificate-authority="$(pwd)/kube_ca.pem" 
- kubectl config set-credentials default-admin --token=$KUBE_TOKEN
- kubectl config set-context default-system --cluster=default-cluster --user=default-admin
- kubectl config use-context default-system
</code></pre>

<p>When i do this it fails with <code>x509: certificate signed by unknown authority</code></p>

<p>I tried going to the google cloud console > cluster > show credentials and instead of the token specify the username and password that it shows me there, this fails with the same error.</p>

<p>Finally i tried using the <code>--insecure-skip-tls-verify=true</code> but then it complains <code>error: You must be logged in to the server (the server has asked for the client to provide credentials)</code></p>

<p>Any Help would be appreciated.</p>

<p>The cause of this problem was an incorrect server url. The server needs to be the one defined on the cluster information page in the google cloud console. You will find an Endpoing ip address.</p>
