gcloud 集群无法拉取 eu.gcr.io 需要身份验证
gcloud cluster cannot pull eu.gcr.io authentication required
我已经通过gitlab在gcloud上搭建了一个Kubernetes集群。
我在部署应用程序时拉取图像时遇到了一些问题。
我在同一个 gcloud 项目上使用带有注册表的 gcloud 集群。通常,我可以不做任何修改直接拉取我的图像(应该使用 Compute Engine 默认服务帐户?)。
但是当他试图拉取图像时,我在我的 pod 上遇到了未经授权的问题:
Warning Failed 3m (x2 over 3m) kubelet, gke-production-default-pool-********-**** Failed to pull image "eu.gcr.io/[My-Project]/services-identity:715bfffa": rpc error: code = Unknown desc = unauthorized: authentication required
Warning Failed 3m (x2 over 3m) kubelet, gke-production-default-pool-********-**** Error: ErrImagePull
Normal BackOff 2m (x6 over 3m) kubelet, gke-production-default-pool-********-**** Back-off pulling image "eu.gcr.io/[My-Project]/services-identity:715bfffa"
Warning Failed 2m (x6 over 3m) kubelet, gke-production-default-pool-********-**** Error: ImagePullBackOff
Normal Pulling 2m (x3 over 3m) kubelet, gke-production-default-pool-********-**** pulling image "eu.gcr.io/[My-Project]/services-identity:715bfffa"
我使用以下命令行通过 gitlab-ci 进行部署:
helm upgrade --install services-identity -f ./deploy/env/production-values.yml ./deploy/ --set image.tag=${CI_COMMIT_SHA:0:8} --namespace=production --wait
有关信息,我可以在这个 public 时拉取注册表,我也可以通过 docker 登录(使用我的 gcloud 帐户)在本地拉取图像。
提前感谢您的建议。
这与此非常相似:,只是您没有提到它在 GKE 上,所以我假设它在 GCE 上。
您可以使用 json_key_file
.
在你所有的节点上(假设你使用的是Docker):
$ docker login -u _json_key --password-stdin https://gcr.io
或相同的 json_key_file 使用 ImagePullSecrets
in the pod spec as described here。
或者您可以在所有 Kubernetes 节点上使用:
$ gcloud auth configure-docker
感谢您的有用回复。关于您分享的类似问题,我找到了解决方案Use Least Privilege Service Accounts for your Nodes。
问题出在 Cloud API 访问范围 级别,我重新创建了具有正确范围的 InstanceGroup:
The default scopes for the nodes in GKE are devstorage.read_only,
logging.write, monitoring, service.management.readonly,
servicecontrol, and trace.append. When setting scopes, these are
specified as gke-default. If you are accessing private images in
Google Container Registry, the minimally required scopes are only
logging.write, monitoring, and devstorage.read_only.
我已经通过gitlab在gcloud上搭建了一个Kubernetes集群。
我在部署应用程序时拉取图像时遇到了一些问题。
我在同一个 gcloud 项目上使用带有注册表的 gcloud 集群。通常,我可以不做任何修改直接拉取我的图像(应该使用 Compute Engine 默认服务帐户?)。
但是当他试图拉取图像时,我在我的 pod 上遇到了未经授权的问题:
Warning Failed 3m (x2 over 3m) kubelet, gke-production-default-pool-********-**** Failed to pull image "eu.gcr.io/[My-Project]/services-identity:715bfffa": rpc error: code = Unknown desc = unauthorized: authentication required
Warning Failed 3m (x2 over 3m) kubelet, gke-production-default-pool-********-**** Error: ErrImagePull
Normal BackOff 2m (x6 over 3m) kubelet, gke-production-default-pool-********-**** Back-off pulling image "eu.gcr.io/[My-Project]/services-identity:715bfffa"
Warning Failed 2m (x6 over 3m) kubelet, gke-production-default-pool-********-**** Error: ImagePullBackOff
Normal Pulling 2m (x3 over 3m) kubelet, gke-production-default-pool-********-**** pulling image "eu.gcr.io/[My-Project]/services-identity:715bfffa"
我使用以下命令行通过 gitlab-ci 进行部署:
helm upgrade --install services-identity -f ./deploy/env/production-values.yml ./deploy/ --set image.tag=${CI_COMMIT_SHA:0:8} --namespace=production --wait
有关信息,我可以在这个 public 时拉取注册表,我也可以通过 docker 登录(使用我的 gcloud 帐户)在本地拉取图像。
提前感谢您的建议。
这与此非常相似:
您可以使用 json_key_file
.
在你所有的节点上(假设你使用的是Docker):
$ docker login -u _json_key --password-stdin https://gcr.io
或相同的 json_key_file 使用 ImagePullSecrets
in the pod spec as described here。
或者您可以在所有 Kubernetes 节点上使用:
$ gcloud auth configure-docker
感谢您的有用回复。关于您分享的类似问题,我找到了解决方案Use Least Privilege Service Accounts for your Nodes。
问题出在 Cloud API 访问范围 级别,我重新创建了具有正确范围的 InstanceGroup:
The default scopes for the nodes in GKE are devstorage.read_only, logging.write, monitoring, service.management.readonly, servicecontrol, and trace.append. When setting scopes, these are specified as gke-default. If you are accessing private images in Google Container Registry, the minimally required scopes are only logging.write, monitoring, and devstorage.read_only.