<h2>Case</h2>
<p>I am following tutorial: <a href="https://codelabs.developers.google.com/codelabs/cloud-springboot-kubernetes?continue=https%3A%2F%2Fdevelopers.google.com%2Flearn%2Fpathways%2Fjava-cloud-fundamentals%23codelab-https%3A%2F%2Fcodelabs.developers.google.com%2Fcodelabs%2Fcloud-springboot-kubernetes#4" rel="nofollow noreferrer">Deploy a Spring Boot Java app to Kubernetes on Google Kubernetes Engine</a> . I came to the step when I want to deploy my application (docker image of it) to kubernetes. But after I create the deployment  the pods are not starting because there is problem with pulling the image (Error: ErrImagePull).</p>
<p>I create the deployment like that:</p>
<pre><code> kubectl create deployment questy-java --image=us-central1-docker.pkg.dev/quizdev/codelabrepo/questy-java:v1
</code></pre>
<p>After running the command:</p>
<pre><code>kubectl describe pod questy-java-54dbd6ccd4-5cb94
</code></pre>
<p>I am getting event information:</p>
<pre><code>Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  36s                default-scheduler  Successfully assigned default/questy-java-54dbd6ccd4-tmdkl to gke-questy-java-cluster-default-pool-ca7ad417-lxkw
  Normal   Pulling    23s (x2 over 35s)  kubelet            Pulling image &quot;us-central1-docker.pkg.dev/quizdev/codelabrepo/questy-java:v1&quot;
  Warning  Failed     23s (x2 over 35s)  kubelet            Failed to pull image &quot;us-central1-docker.pkg.dev/quizdev/codelabrepo/questy-java:v1&quot;: rpc error: code = Unknown desc = failed to pull and unpack image &quot;us-central1-docker.pkg.dev/quizdev/codelabrepo/questy-java:v1&quot;: failed to resolve reference &quot;us-central1-docker.pkg.dev/quizdev/codelabrepo/questy-java:v1&quot;: failed to authorize: failed to fetch oauth token: unexpected status: 403 Forbidden
  Warning  Failed     23s (x2 over 35s)  kubelet            Error: ErrImagePull
  Normal   BackOff    8s (x2 over 35s)   kubelet            Back-off pulling image &quot;us-central1-docker.pkg.dev/quizdev/codelabrepo/questy-java:v1&quot;
  Warning  Failed     8s (x2 over 35s)   kubelet            Error: ImagePullBackOff
</code></pre>
<p>The root couse seems to be mentioned in here:</p>
<blockquote>
<p>failed to authorize: failed to fetch oauth token: unexpected status:
403 Forbidden</p>
</blockquote>
<p>Anyhow the tutorial did not mention any additional steps to mantain authentication or authorisation.</p>
<h2>What I have tried:</h2>
<ol>
<li>I have checked the VPC networks dashboard to see if Private Google Access is enabled and it looks fine:</li>
</ol>
<p><a href="https://i.stack.imgur.com/aUUVw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aUUVw.png" alt="enter image description here" /></a></p>
<ol start="2">
<li>I have followed instructions to install gke-gcloud-auth-plugin from: <a href="https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke" rel="nofollow noreferrer">https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke</a>. Recreating the deployment after this change did not help.</li>
<li>Created new repository in the Artifact Registry and tried to deploy my image there</li>
<li>build  an entirely new Docker container and tried to deploy it in new repository</li>
<li>Tried to deploy questy-java image directly from Google Cloud Console:
<a href="https://i.stack.imgur.com/32UWM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/32UWM.png" alt="enter image description here" /></a></li>
</ol>
<hr />
<ol start="6">
<li>Run the command:</li>
</ol>
<pre><code>    gcloud auth configure-docker us-central1-docker.pkg.dev
</code></pre>
<ol start="7">
<li>Checked the path throughly. I have copied and paste the path to the image directly from Console:
<a href="https://i.stack.imgur.com/uH8Oe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uH8Oe.png" alt="enter image description here" /></a>
I have also tried to run the commands:</li>
</ol>
<pre><code>    docker pull \
        us-central1-docker.pkg.dev/quizdev/codelabrepo/questy-java:v1
</code></pre>
<p>It was successfull.</p>
<h2>Question</h2>
<p>What could be the reason of this error? What is the most elegant way to fix the issue?</p>
<h2>Edit</h2>
<p>I have checked the path to the image directly from Console and it is</p>
<pre><code>  us-central1-docker.pkg.dev/quizdev/codelabrepo/questy-java:v1
</code></pre>

fascynacja
<p>I have followed the tips from @Hemanth Kumar and finaly what solved my problem was adding a Artifact Registry Reader role for specific repository to the service account user which runs in GKE.</p>
<p>I did it via Google Cloud Console:
<a href="https://i.stack.imgur.com/yuUhT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yuUhT.png" alt="enter image description here" /></a></p>
