gcloud不添加用于连接到GKE集群的访问令牌 [英] gcloud does not add access token for connecting to GKE cluster
问题描述
我创建了一个GKE集群,并用kubectl
连接到它,并在我的集群上单击连接"按钮时运行了出现的命令.
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
在$HOME/.kube/config
中,我看到以下条目:
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
这会导致错误:
error: No Auth Provider found for name "gcp"
我重复了在Google Cloud Shell中添加凭据的步骤.在那里,我能够成功创建一个新的命名空间.我注意到access-token
和expiry
字段是可见的.
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
因此,如何获取gcloud containers cluster get-credentials
命令以正确更新我的kubeconfig
?
Therefore, how do I get the gcloud containers cluster get-credentials
command to update my kubeconfig
correctly?
推荐答案
我遇到了这个确切的问题,结果发现我的客户已经过时了.为客户端运行v1.11且我的集群为1.15+,这给了我no auth provider
错误.
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.
按照此处中的说明进行操作,以获取客户端v1.18版本解决了我的问题.
Followed the instructions here to get up to client v1.18 and solved my issue.
这篇关于gcloud不添加用于连接到GKE集群的访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!