Deploying an app to gke from CI

8/11/2017

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

I want to use kubectl apply to deploy new versions of my containers.

This all works from my local machine because it uses my google account.

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

- echo "$KUBE_CA_PEM" > 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

When i do this it fails with x509: certificate signed by unknown authority

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.

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

Any Help would be appreciated.

-- Alex Edwards
gitlab
google-kubernetes-engine
kubernetes

1 Answer

8/11/2017

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.

-- Alex Edwards
Source: StackOverflow