<p>I have customized the coredns image and pushed it to my azure container registry (ACR). <br/>Now in default coredns pod that is coming after k3s installation, I want to use <code>my_azure_acr_repo/proj/customize-coredns:latest</code> image <strong>instead of</strong> <code>rancher/coredns-coredns:1.8.3</code>. So I edited the coredns deployment <code>kubectl edit deploy coredns -n kube-system</code> and replaced my acr image with rancher one. But now coredns pod is not able to pull my acr image and giving error in pod description:</p>
<pre><code>Failed to pull image &quot;my_azure_acr_repo/proj/customize-coredns:latest&quot;: rpc error:
code = Unknown desc = failed to pull and unpack image &quot;my_azure_acr_repo/proj/customize-coredns:latest&quot;: 
failed to resolve reference &quot;my_azure_acr_repo/proj/customize-coredns:latest&quot;: failed to 
authorize: failed to fetch anonymous token: unexpected status: 401 Unauthorized
</code></pre>
<p>How can I authenticate acr image, so that pod should pull it ?</p>

solveit
<p>That's because your container is not authorized to pull image from your private ACR.</p>
<p>First you've to create secret so that you can access your ACR, then pass that secret in your deployment using <code>imagePullSecrets</code></p>
<p>you can create secret by this command, make sure to replace your credential variables</p>
<pre><code>kubectl create secret docker-registry &lt;name&gt; --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL
</code></pre>
<p>For ACR it will be something like this</p>
<pre><code>kubectl create secret docker-registry regkey --docker-server=https://myregistry.azurecr.io --docker-username=ACR_USERNAME --docker-password=ACR_PASSWORD --docker-email=ANY_EMAIL_ADDRESS
</code></pre>
<p>your deployment spec</p>
<pre><code>spec:
  containers:
    - name: foo
      image: janedoe/awesomeapp:v1
  imagePullSecrets:
    - name: regkey

</code></pre>
<p>More info related to this.</p>
<p><a href="https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod" rel="noreferrer">https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod</a></p>
