{"id":356,"date":"2020-10-03T07:06:55","date_gmt":"2020-10-03T07:06:55","guid":{"rendered":"https:\/\/rejupillai.com\/?p=356"},"modified":"2026-04-13T00:09:12","modified_gmt":"2026-04-13T00:09:12","slug":"shared-gcr-for-multiple-gke-projects-errimagepull","status":"publish","type":"post","link":"https:\/\/rejupillai.com\/index.php\/2020\/10\/03\/shared-gcr-for-multiple-gke-projects-errimagepull\/","title":{"rendered":"Shared GCR for multiple GKE Projects"},"content":{"rendered":"\n<p>It is not uncommon to keep all our GCR private registries in a shared Project, and access it from multiple different GCP Projects such as dev, test and prod. In a normal scenario i.e. when the GCR &amp; GKE are in the same Project, you wouldn&#8217;t see an issue, but when they are different you may encounter an ErrImagePull when GKE kubelet tries to pull down the image.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"122\" src=\"https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-1024x122.png\" alt=\"\" class=\"wp-image-357\" srcset=\"https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-1024x122.png 1024w, https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-300x36.png 300w, https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-768x92.png 768w, https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-1170x140.png 1170w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The solution is very simple however.  <\/p>\n\n\n\n<p>In my example I have 2 Projects &#8211; <\/p>\n\n\n\n<p>GKE : reju-pr1<\/p>\n\n\n\n<p>GCR : reju-pr2<\/p>\n\n\n\n<p><em>project names have been masked <\/em><\/p>\n\n\n\n<p>Step 1) Go to IAM module of the GKE Project, and find the service account  that corresponds to the <code>Compute Engine default service account<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"359\" src=\"https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-1-1024x359.png\" alt=\"\" class=\"wp-image-358\" srcset=\"https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-1-1024x359.png 1024w, https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-1-300x105.png 300w, https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-1-768x270.png 768w, https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-1-1170x411.png 1170w, https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-1.png 2006w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Step 2) Navigate to the IAM section of the second project  (where GCR is hosted) and <code>Add a Member<\/code> with the same service account id noted from Step 1 ; give it a role of <strong>Storage Object Viewer<\/strong>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"882\" src=\"https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-2-1024x882.png\" alt=\"\" class=\"wp-image-359\" srcset=\"https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-2-1024x882.png 1024w, https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-2-300x258.png 300w, https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-2-768x661.png 768w, https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-2-1170x1007.png 1170w, https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-2.png 1352w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Step 3) Delete the deployments and force the pods to be recreated, you will see that images are successfully <em>pulled<\/em> down this time around.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"323\" src=\"https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-3-1024x323.png\" alt=\"\" class=\"wp-image-360\" srcset=\"https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-3-1024x323.png 1024w, https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-3-300x95.png 300w, https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-3-768x242.png 768w, https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-3-1170x369.png 1170w, https:\/\/rejupillai.com\/wp-content\/uploads\/2020\/10\/image-3.png 1460w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>The hipster store app is fully deployed and running.<\/figcaption><\/figure>\n\n\n\n<p>Conclusion : When using GCR across Projects make sure to provide the <code><code><code><code><code><code>Storage Object Viewer<\/code><\/code><\/code><\/code><\/code><\/code> Role to the ServiceAccount responsible for pulling the images on the GKE nodes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is not uncommon to keep all our GCR private registries in a shared Project, and access it from multiple different GCP Projects such as dev, test and prod. In a normal scenario i.e. when the GCR &amp; GKE are in the same Project, you wouldn&#8217;t see an issue, but<\/p>\n","protected":false},"author":1,"featured_media":191,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-356","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-google-cloud","ct-col-2"],"_links":{"self":[{"href":"https:\/\/rejupillai.com\/index.php\/wp-json\/wp\/v2\/posts\/356","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rejupillai.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rejupillai.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rejupillai.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rejupillai.com\/index.php\/wp-json\/wp\/v2\/comments?post=356"}],"version-history":[{"count":13,"href":"https:\/\/rejupillai.com\/index.php\/wp-json\/wp\/v2\/posts\/356\/revisions"}],"predecessor-version":[{"id":427,"href":"https:\/\/rejupillai.com\/index.php\/wp-json\/wp\/v2\/posts\/356\/revisions\/427"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rejupillai.com\/index.php\/wp-json\/wp\/v2\/media\/191"}],"wp:attachment":[{"href":"https:\/\/rejupillai.com\/index.php\/wp-json\/wp\/v2\/media?parent=356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rejupillai.com\/index.php\/wp-json\/wp\/v2\/categories?post=356"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rejupillai.com\/index.php\/wp-json\/wp\/v2\/tags?post=356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}