Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcloud does not add access token for connecting to GKE cluster

I created a GKE cluster and to connect to it with kubectl ran the command that appears when clicked on Connect button against my cluster.

gcloud container clusters get-credentials cluster-name --zone us-central1-a --project project-id

In $HOME/.kube/config I see entries as below:

- name: cluster-name
  user:
    auth-provider:
      config:
        cmd-args: config config-helper --format=json
        cmd-path: /usr/lib64/google-cloud-sdk/bin/gcloud
        expiry-key: '{.credential.token_expiry}'
        token-key: '{.credential.access_token}'
      name: gcp

To add a new namespace, I did the following:

kubectl config use-context cluster-name
kubectl create namespace demo

This results in error:

error: No Auth Provider found for name "gcp"

I repeated the step of adding the credentials in the Google Cloud shell. There, I am able to create a new namespace successfully. I noticed that, the access-token and expiry fields are visible.

auth-provider:
      config:
        access-token: omitted
        cmd-args: config config-helper --format=json
        cmd-path: /google/google-cloud-sdk/bin/gcloud
        expiry: "2019-12-10T03:39:53Z"
        expiry-key: '{.credential.token_expiry}'
        token-key: '{.credential.access_token}'
      name: gcp

Therefore, how do I get the gcloud containers cluster get-credentials command to update my kubeconfig correctly?

like image 810
cogitoergosum Avatar asked Dec 06 '25 05:12

cogitoergosum


1 Answers

I ran into this exact problem, and it turned out my client was out of date. Running v1.11 for the client and my cluster was 1.15+ gave me the no auth provider error.

Followed the instructions here to get up to client v1.18 and solved my issue.

like image 120
justincely Avatar answered Dec 08 '25 11:12

justincely



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!