Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error "certificate signed by unknown authority" after switching GCP project

After switching gcloud projects using ...

gcloud init

... and then try to do some kubectl command, like this for instance:

kubectl get rc

... I get this error:

error: couldn't read version from server: Get
https://130.211.59.254/api: x509: certificate signed by unknown authority

Why is this and how can I solve it?

like image 767
Mattias Petter Johansson Avatar asked Mar 16 '16 07:03

Mattias Petter Johansson


2 Answers

This is because the keys to your old cluster is cached. I'm not sure why they are not updated by the gcloud init command (that's what one would intuitively expect, or at least some kinder error message from kubectl)

You solve it by simply getting the credentials of the cluster in the new configuration:

gcloud container clusters get-credentials YOURCLUSTERHERE --zone YOURCLUSTERZONEHERE
like image 110
Mattias Petter Johansson Avatar answered Nov 11 '22 18:11

Mattias Petter Johansson


This can be resolved by fetching the credential

gcloud container clusters get-credentials   < container-cluster >    --zone < zone >  --project   < project name >

Or

login to GCP

GCP -> container engine -> container clusters -> connect to cluster

Refer this docs for further information

https://cloud.google.com/sdk/gcloud/reference/container/clusters/get-credentials

like image 30
RahulKrishnan R A Avatar answered Nov 11 '22 18:11

RahulKrishnan R A