I have seen a couple of solutions for this, all mention just to run gcloud auth login and gcloud container clusters get-credentials ..., but I still get the error.
Eg., if I run kubectl version, I get:
Client Version: version.Info{Major:"1", Minor:"15+", GitVersion:"v1.15.11-dispatcher", GitCommit:"f2a77f678d6baccda27740d700f6cba2754dfacf", GitTreeState:"clean", BuildDate:"2020-04-21T04:42:07Z", GoVersion:"go1.12.17", Compiler:"gc", Platform:"linux/amd64"}
Unable to connect to the server: x509: certificate signed by unknown authority
I have installed gcloud SDK using these instructions: https://cloud.google.com/sdk/docs/downloads-versioned-archives (tried other instructions, but the outcome was same ...)
Cluster is not private so it doesn't need this: https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl#internal_ip
I have installed kubectl with gcloud components install kubectl and when running which kubectl I confirmed that correct one is called:
/home/ajuric/google-cloud-sdk/bin/kubectl
Of course, if I use kubectl from the Cloud Shell, everything works, but I need to use kubectl from my local machine.