kubectl 访问 Google Cloud Container Engine 失败

kubectl access to Google Cloud Container Engine fails

在 Google 云平台中,我有一个包含三个 运行ning 实例的容器集群。我现在想从我的终端连接,以便能够执行 运行 kubectl 命令。为此,我 运行 命令

gcloud container clusters get-credentials cluster-1 --zone europe-west1-b --project project-id

当然我用的是真实的项目名。这是单击 'connect with the cluster' 时仪表板显示的命令。此命令的输出为:

Fetching cluster endpoint and auth data.
kubeconfig entry generated for cluster-1.

但是当我 运行 kubectl 之后像 kubectl cluster-info 这样的命令时,我总是得到:

Unable to connect to the server: oauth2: cannot fetch token: 400 Bad Request
Response: {
  "error" : "invalid_grant",
  "error_description" : "Token has been revoked."
}

我在这里错过了什么? gcloud 类似 gcloud container clusters list 的命令有效

我在家里的另一台机器上尝试过,在安装和设置 gcloud 后它可以正常工作。我认为在我的工作机器上仍然存储了一个 oauth 令牌,我用它验证了我用于测试的另一个 google 帐户。

编辑: 我现在明白了 运行。问题是我错过了第二个必要的电话:

gcloud auth login
gcloud auth application-default login