4

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?

cogitoergosum
  • 2,309
  • 4
  • 38
  • 62
  • Is there any reason you ran `kubectl config use-context cluster-name` command? It is not clear what's your problem, and what are you trying to do. – suren Dec 10 '19 at 08:03
  • Where did you run these commands? In your local terminal? Did you run `gcloud auth login` to authenticate before you ran `gcloud container clusters get-credentials`? – LundinCast Dec 10 '19 at 09:15
  • Yes, the commands were run on my local terminal. Yes, `gcloud auth login` was run before getting credentials. – cogitoergosum Dec 10 '19 at 09:32
  • Most likely something went wrong with 'gcloud container clusters get-credentials', could you add the ['--verbosity="debug"' flag](https://cloud.google.com/sdk/gcloud/reference/#--verbosity) to the command and share the output of it? – rsalinas Dec 10 '19 at 14:42
  • Ok. In the meatime, found this one similar to issue I am facing. I am not sure, I follow the answer though - https://stackoverflow.com/a/48182401/919480 – cogitoergosum Dec 10 '19 at 14:58

1 Answers1

1

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.

justincely
  • 955
  • 7
  • 12