<p>I am having trouble pulling images from GCR ( pulled by my deployments )
I got <strong>ImagePullBackOff</strong> error.</p>

<p>I have followed this tutorial already, step by step.</p>

<p><a href="https://container-solutions.com/using-google-container-registry-with-kubernetes/" rel="nofollow noreferrer">https://container-solutions.com/using-google-container-registry-with-kubernetes/</a></p>

<p>However it doesn't seem to work for me. I have even tried using the <strong>Storage Admin</strong> role when creating the service account key but its still no use.</p>

<p>When describing the pod, I got this error:</p>

<pre><code>  Warning  Failed                 14s (x2 over 30s)  kubelet, docker-for-desktop  Failed to pull image "gcr.io/&lt;project-name&gt;/&lt;image-name&gt;": rpc error: code = Unknown desc = Error response from daemon: Get https://gcr.io/v2/&lt;project-name&gt;/&lt;image-name&gt;/manifests/latest: unknown: Unable to parse json key.
  Warning  Failed                 14s (x2 over 30s)  kubelet, docker-for-desktop  Error: ErrImagePull
  Normal   BackOff                2s (x3 over 29s)   kubelet, docker-for-desktop  Back-off pulling image "gcr.io/&lt;project-name&gt;/&lt;image-name&gt;"
  Warning  Failed                 2s (x3 over 29s)   kubelet, docker-for-desktop  Error: ImagePullBackOff
</code></pre>

<p>When visiting the <strong><a href="https://gcr.io/v2/" rel="nofollow noreferrer">https://gcr.io/v2/</a><em>project-name</em>/<em>image-name</em>/manifests/latest</strong> url, I got this:</p>

<pre><code>// 20181124152036
// https://gcr.io/v2/project-name/image-name/manifests/latest

{
  "errors": Array[1][
    {
      "code": "UNAUTHORIZED",
      "message": "You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication"
    }
  ]
}
</code></pre>

<p><strong>Pod Definition:</strong></p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: microservice-1-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: microservice-1
  template:
    metadata:
      labels:
        app: microservice-1
    spec:
      containers:
        - name: microservice-1
          image: gcr.io/project-name/image-name
          ports:
            - containerPort: 80
</code></pre>

<p><strong>Notes:</strong></p>

<p>My deployments are able to pull images when they where hosted on docker hub, issue only occurs on pulling images in GCR.</p>

<p><strong>Env</strong></p>

<ul>
<li>Windows 10 </li>
<li>Docker Version 2.0.0.0-win78 (28905)</li>
<li>Kubernetes 1.10.3 (Included on docker for desktop)</li>
</ul>

<p>I hope you can help me on this,</p>

<p>Thanks in advance</p>

Jplus2
<p>OK found the culprit, it has something to do with <strong>Powershell</strong> and <strong>Command Prompt</strong>.</p>

<p>I switched to using <strong>Git Bash</strong> and followed the same instructions in this tutorial</p>

<p><a href="https://container-solutions.com/using-google-container-registry-with-kubernetes/" rel="nofollow noreferrer">https://container-solutions.com/using-google-container-registry-with-kubernetes/</a></p>

<p>and it worked! </p>

<p>Probably the culprit occurred when creating <strong>imagePullSecrets</strong> on <strong>Powershell</strong> and/or <strong>Command Prompt</strong>. Something probably went wrong when reading the json file, related to encoding or something.</p>

<p>Hope this helps anyone.</p>
