DEV Community

meddlesome
meddlesome

Posted on

Solving kubectl authentication error on GKE

When you executing kubectl command to your cluster on GKE. It will thrown some error like

$ kubectl get namespaces
error: The gcp auth plugin has been removed.
Please use the "gke-gcloud-auth-plugin" kubectl/client-go credential plugin instead.
See https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke for further details
Enter fullscreen mode Exit fullscreen mode

As GKE change the way to authentication more safely. then we need to upgrade our GKE authentication

But Even installing gcloud components install gke-gcloud-auth-plugin and set export USE_GKE_GCLOUD_AUTH_PLUGIN=True might be still not working. Since an existing "Kube context" (credentials) still exist. You need to remove and fetch kube context again.

Here is overall trick to solve the problem

$ gcloud components install gke-gcloud-auth-plugin
$ echo 'export USE_GKE_GCLOUD_AUTH_PLUGIN=True' >> ~/.bashrc
$ source ~/.bashrc
$ gcloud components update
$ cp ~/.kube/config ~/.kube/config.backup && rm ~/.kube/config
$ gcloud container clusters get-credentials {{GKE_CLUSTER_NAME}} --region {{GKE-REGION}} --project {{GCP_PROJECT_NAME}}
Enter fullscreen mode Exit fullscreen mode

Latest comments (0)