问题
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