【问题标题】:gcloud does not add access token for connecting to GKE clustergcloud 不添加访问令牌以连接到 GKE 集群
【发布时间】:2020-04-03 05:03:24
【问题描述】:

我创建了一个 GKE 集群并使用 kubectl 连接到它,运行了在我的集群上单击“连接”按钮时出现的命令。

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

$HOME/.kube/config 我看到以下条目:

- 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

要添加新的命名空间,我做了以下操作:

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

这会导致错误:

error: No Auth Provider found for name "gcp"

我重复了在 Google Cloud shell 中添加凭据的步骤。在那里,我能够成功创建一个新的命名空间。我注意到,access-tokenexpiry 字段是可见的。

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

【问题讨论】:

  • 您有什么理由运行kubectl config use-context cluster-name 命令吗?目前尚不清楚您的问题是什么,以及您要做什么。
  • 你在哪里运行这些命令?在您的本地终端?在运行gcloud container clusters get-credentials 之前是否运行gcloud auth login 进行身份验证?
  • 是的,这些命令是在我的本地终端上运行的。是的,gcloud auth login 是在获取凭据之前运行的。
  • “gcloud container clusters get-credentials”很可能出现问题,您能否将'--verbosity="debug"' flag 添加到命令中并分享它的输出?
  • 好的。在metime中,发现了一个与我面临的问题类似的问题。我不确定,但我会按照答案 - stackoverflow.com/a/48182401/919480

标签: kubernetes google-cloud-platform gcloud kubeconfig


【解决方案1】:

我遇到了这个确切的问题,结果发现我的客户端已经过时了。为客户端运行 v1.11 并且我的集群是 1.15+ 给了我no auth provider 错误。

按照说明 here 升级到客户端 v1.18 并解决了我的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-01
    • 2018-09-14
    • 2021-11-03
    • 2021-10-09
    • 2018-07-02
    • 2021-12-06
    • 2020-10-01
    • 1970-01-01
    相关资源
    最近更新 更多