gcloud does not add access token for connecting to GKE cluster

久未见 提交于 2020-01-25 10:16:09

问题


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?

来源:https://stackoverflow.com/questions/59259960/gcloud-does-not-add-access-token-for-connecting-to-gke-cluster

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!