LoginSignup
10
3

More than 3 years have passed since last update.

GCRからimage pullできない

Last updated at Posted at 2018-12-11

絶対に忘れるのでメモ

GCRからimage pullできる状態

  • GCRに目的のimage:tagがある
  • image pullしようとしているIAMユーザーで認証済みである
  • image pullしようとしているIAMユーザーに Storage Object Viewer のRoleが付与されている

GCRからローカルへimage pullできない

IAMの権限が足りていないかアカウントが間違っていると思われるのでIAMの権限を確認して再認証する。

$ gcloud auth configure-docker

The following settings will be added to your Docker config file
located at [/Users/ota/.docker/config.json]:
 {
  "credHelpers": {
    "gcr.io": "gcloud",
    "us.gcr.io": "gcloud",
    "eu.gcr.io": "gcloud",
    "asia.gcr.io": "gcloud",
    "staging-k8s.gcr.io": "gcloud",
    "marketplace.gcr.io": "gcloud"
  }
}

Do you want to continue (Y/n)?  Y

Docker configuration file updated.

docker pull

$ docker pull gcr.io/repository/image:tag
a5a6f2f73cd8: Pull complete
6fd77ab8da06: Pull complete
38f41ceffa9f: Pull complete
0780bb3d4637: Pull complete
3fc5d8beb4e0: Pull complete
0b99174e07e3: Pull complete
3e4d69c9cf58: Pull complete
63a70b7812b2: Pull complete
0186376c89a6: Pull complete
Digest: sha256:ca61918b0f9f20a062c55e68219a811bca09dd052046eba929933411bcc97060
Status: Downloaded newer image for gcr.io/repository/image:tag

GKEへデプロイしたpodsがImagePullBackOffになる

これはGKEのノード(GCE)に設定されているサービスアカウントの権限が足りていないためIAMにてGCR(もといGCS)のViewer権限を追加することで解消する。

the Compute Engine default service account of another project. This account is used by the Google Kubernetes Engine to pull container images clusters by default. It is in the form [PROJECT_NUMBER]-compute@developer.gserviceaccount.com, where [PROJECT-NUMBER] is the GCP project number of the project that is running the Google Kubernetes Engine cluster.

とあるのでIAMの設定で
[PROJECT_NUMBER]-compute@developer.gserviceaccount.comStorage Object Viewer の権限を付与すればOK。

iam.png

Cloud Buildでもimage pullに失敗する

GKEと同様
Cloud Buildのサービスアカウント [PROJECT_NUMBER]-cloudbuild.gserviceaccount.comStorage Object Viewer の権限を付与すればOK。

10
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
3