<p>I'm using JFrog repository as my private registry. And I have specified the secret in order to authenticate with the JFrog. But it says</p>
<pre><code>Failed to pull image &quot;private_registry/image_name&quot;: rpc error: code = Unknown desc = failed to pull and unpack image &quot;private_registry/image_name&quot;: failed to resolve reference &quot;&quot;: failed to authorize: failed to fetch oauth token: unexpected status: 401 Unauthorized
  Warning  Failed     2s (x2 over 14s)  kubelet, worker-0  Error: ErrImagePull
</code></pre>
<p><a href="https://i.stack.imgur.com/FKsxq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FKsxq.png" alt="Pod-Def.yml" /></a></p>
<p>I have created a secret file too. But still it doesn't pull the image. When I do <code>docker image pull private_registry/image_name</code> the image get pulled.</p>

Dusty
<p>From the question, it's clear that it's not able to authenticate for some reason,
It could be a misconfiguration of the secret also possible that the credential used is/are not valid.</p>
<p>Since the <code>secret.yaml</code> file is not present, not aware of the format.</p>
<p>In this case, I would suggest looking at 2 things</p>
<ol>
<li>Check if the credentials are correct. (In this case, probably you can use <code>docker pull</code> after <code>docker login</code> with the same credential)</li>
</ol>
<p>If you are able to pull the image successfully, take a look at the next point.</p>
<ol start="2">
<li>In this, you have the check the way you configure or pass the credentials in the chart is correct.</li>
</ol>
<p>There are different ways to pass credentials in different cases,
you can take a look at this <a href="https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/" rel="nofollow noreferrer">official doc.</a>
and <a href="https://devops.stackexchange.com/questions/4013/how-to-pull-a-docker-image-from-a-private-docker-registry-using-helm/4016#4016">here</a> in devops exchange the answer also might help to get some insight.</p>
<p>and here is how my <code>secret.yaml</code> looks like:</p>
<pre><code>---
apiVersion: v1
kind: Secret
metadata:
  name: {{ .Chart.Name }}-docker-credentials
  namespace: {{ .Release.Namespace }}
  labels:
    app: {{ .Chart.Name }}
    chart: &quot;{{ .Chart.Name }}-{{ .Chart.Version }}&quot;
    release: &quot;{{ .Release.Name }}&quot;
type: kubernetes.io/dockercfg
data:
  .dockercfg: {{ &quot;{\&quot;.Values.REGISTRY.URL&gt;&gt;/\&quot;:{\&quot;username\&quot;:\&quot;.Values.REGISTRY.USER_NAME&gt;&gt;\&quot;,\&quot;password\&quot;:\&quot;.Values.REGISTRY.PASSWORD&gt;&gt;\&quot;,\&quot;email\&quot;:\&quot;.Values.REGISTRY.EMAIL&gt;&gt;\&quot;,\&quot;auth\&quot;:\&quot;.Values.REGISTRY.AUTH_TOKEN&gt;&gt;\&quot;}}&quot; | b64enc | quote }}


</code></pre>
<p>in the deployments i do:</p>
<pre><code>spec:
   imagePullSecrets:
      - name: {{ .Chart.Name }}-docker-credentials
</code></pre>
<p><em>Since you have already resolved, hope this would help someone else.😃</em></p>
