从Google Container Engine/Kubernetes 1.4.5开始,CLI 身份验证过程是什么?



当前必须经过哪些步骤才能对Google Container Engine/Kubernetes 1.4.5进行身份验证?

当我今天设置第三个Google Cloud项目时,我经历了我以前的GKE集群设置流程不再工作。我的流程如下:

gcloud auth login
gcloud config set compute/region europe-west1
gcloud config set compute/zone europe-west1-d
gcloud config set project myproject
gcloud container clusters get-credentials staging
# An example of a typical kubectl command to see that you've got the right cluster
kubectl get pods --all-namespaces

虽然这曾经完美地工作,但我现在在试图查询集群时得到权限错误,例如kubectl get pods会发出以下错误消息:the server does not allow access to the requested resource (get pods)

在来回搜索之后,我意识到kubectl依赖于一个叫做Application Default Credentials的东西。在某些时候,我还偶然注意到gcloud auth login发出以下内容:
WARNING: `gcloud auth login` no longer writes application default credentials.
If you need to use ADC, see:
  gcloud auth application-default --help

所以我最终意识到,使用当前的gcloud/Kubernetes版本,我还需要调用gcloud auth application-default,以便使用我当前帐户的凭据,而不是先前激活的项目的凭据。

所以,我希望有人能澄清什么是实际的身份验证工作流程谷歌容器引擎/Kubernetes版本1.4.5??

你找到正确答案了。kubectl的GCP身份验证插件只支持应用程序默认凭证,它最近与gcloud的标准凭证解耦了。因此,在1.4.5中,您需要运行gcloud auth application-default login以确保kubectl正在使用您期望的凭据。

我们认为大多数用户只是希望使用与gcloud相同的凭据,ADC对于一些可能甚至没有安装gcloud的服务帐户场景很有用。因此,有一个pull请求Kubernetes添加一个"使用gcloud凭据"选项到kubectl gcp身份验证插件。这应该在kubectl 1.5中可用。

最新更新