<p>I have a private Docker repo with bunch of images. I am using Helm to deploy them to a Kubernetes cluster. </p>

<p>Helm values.yaml contains the repository credentials:</p>

<pre><code>image:
  repository: &lt;repo&gt;
  tag: &lt;version tag&gt;
  pullPolicy: IfNotPresent
  imageCredentials:
    registry: &lt;repo&gt;
    username: &lt;username&gt;
    password: &lt;pw&gt;
</code></pre>

<p>After doing the helm installation </p>

<blockquote>
  <p>helm install myhelmchart --values values.yaml --version </p>
</blockquote>

<p>the pod's status is Init:ErrImagePull.
kubectl describe pods gives this error:     </p>

<blockquote>
  <p>Failed to pull image "image:tag": rpc error: code = Unknown desc =
  Error response from daemon: Get [image]/manifests/[version]:
  unauthorized: authentication required</p>
</blockquote>

<p>It depends on the output of your helm chart. You can use <code>helm template</code> to see the resulting kubernetes resources without actually deploying it. Using an image from a private docker registry comes down to two steps:</p>

<ol>
<li><p>Make sure that you have a <a href="https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-in-the-cluster-that-holds-your-authorization-token" rel="noreferrer"><code>secret</code> resource</a> for the private repository. Note that the type here is <code>kubernetes.io/dockerconfigjson</code> or <code>kubernetes.io/dockercfg</code>.</p>

<p>How to create this with templates from helm is described <a href="https://helm.sh/docs/howto/charts_tips_and_tricks/#creating-image-pull-secrets" rel="noreferrer">here</a>.</p></li>
<li>Refer to that secret in the pod that uses the image from that private repository, as shown below:</li>
</ol>

<p>Pod resource/template:</p>

<pre><code>spec:
  containers:
  - name: some-pod
    image: &lt;image&gt;
  imagePullSecrets:
  - name: &lt;name-of your secret&gt;
</code></pre>

<p>You can first build the resources by hand without helm. This helps to verify that the resources themselves are correct. Then you can adapt the helm templates to output the correct resources given your values.</p>
