<p>I am creating a deployment in circlci that deploys my containerized application to a k3s server I have set up. I have set up a secret using the commands found <a href="https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/" rel="nofollow noreferrer">here</a>.</p>
<p>The secret is created using the command:</p>
<pre><code>kubectl create secret docker-registry regkeyname --docker-server=https://index.docker.io/v1/ \
 --docker-username=username  \
 --docker-password=password  \
 --docker-email=my@email.com \
 --namespace=external
</code></pre>
<p>My secret is as follows when running <code>kubectl get secret regkeyname --namespace=external --output=yaml</code>:</p>
<pre><code>apiVersion: v1
data:
  .dockerconfigjson: secretbase64stuff
kind: Secret
metadata:
  creationTimestamp: &quot;2020-11-24T13:11:07Z&quot;
  managedFields:
    - apiVersion: v1
      fieldsType: FieldsV1
      fieldsV1:
        f:data:
          .: {}
          f:.dockerconfigjson: {}
        f:type: {}
      manager: kubectl
      operation: Update
      time: &quot;2020-11-24T13:11:07Z&quot;
  name: regkeyname
  namespace: external
  resourceVersion: &quot;16929381&quot;
  selfLink: /api/v1/namespaces/external/secrets/regkeyname
  uid: 51b87508-9cf2-490b-b871-0b5a342ab64c
type: kubernetes.io/dockerconfigjson
</code></pre>
<p>I'm using helm to deploy my application and the Deployment looks like this:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Values.labels.app }}
  labels:
    app: {{ .Values.labels.app }}
spec:
  selector:
    matchLabels:
      app: {{ .Values.labels.app }}
  replicas: 3
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  template:
    metadata:
      labels:
        app: {{ .Values.labels.app }}
        env: {{ .Values.labels.env }}
    spec:
      imagePullSecrets:
        - name: regkeyname
      containers:
        - name: my-service
          image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
          imagePullPolicy: {{ .Values.image.imagePullPolicy }}
          readinessProbe:
            httpGet:
              path: /health
              port: 8080
            initialDelaySeconds: 10
            periodSeconds: 10
            failureThreshold: 5
            successThreshold: 1
</code></pre>
<p>after deploying however, the images fail to pull and it appears that my secret &quot;regkeyname&quot; is not used/mounted in the pods. the result is as follows:</p>
<pre><code>Name:           my-service-856454c6cd-qcp7w
Namespace:      external
Priority:       0
Node:           worker-2/192.168.1.13
Start Time:     Tue, 24 Nov 2020 07:20:08 -0600
Labels: app=my-service
  env=development
  pod-template-hash=856454c6cd
Annotations:    &lt;none&gt;
Status:         Pending
IP:             10.42.2.196
Controlled By:  ReplicaSet/my-service-856454c6cd
Containers:
  auth-service:
    Container ID:
    Image:          my-repo/my-service:latest
    Image ID:
    Port:           &lt;none&gt;
    Host Port:      &lt;none&gt;
    State:          Waiting
      Reason:       ImagePullBackOff
    Ready:          False
    Restart Count:  0
    Readiness:      http-get http://:8080/health delay=10s timeout=1s period=10s #success=1 #failure=5
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-l9b4k (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  default-token-l9b4k:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-l9b4k
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  &lt;none&gt;
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
  node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason     Age                    From                  Message
  ----     ------     ----                   ----                  -------
  Normal   Scheduled  &lt;unknown&gt;              default-scheduler     Successfully assigned external/auth-service-856454c6cd-qcp7w to worker-2
  Normal   Pulling    32m (x4 over 34m)      kubelet, worker-2  Pulling image &quot;my-repo/my-service:latest&quot;
  Warning  Failed     32m (x4 over 34m)      kubelet, worker-2  Failed to pull image &quot;my-repo/my-service:latest&quot;: rpc error: code = Unknown desc = failed to pull and unpack image &quot;docker.io/my-repo/my-service:latest&quot;: failed to resolve reference &quot;docker.io/my-repo/my-service:latest&quot;: failed to do request: Head https://registry-1.docker.io/v2/my-repo/my-service/manifests/latest: dial tcp: lookup registry-1.docker.io: Try again
  Warning  Failed     32m (x4 over 34m)      kubelet, worker-2  Error: ErrImagePull
  Warning  Failed     31m (x6 over 34m)      kubelet, worker-2  Error: ImagePullBackOff
  Normal   BackOff    3m54s (x127 over 34m)  kubelet, worker-2  Back-off pulling image &quot;my-repo/my-service:latest&quot;
</code></pre>
<p>I had this working when running locally with kubernetes so I am assuming the issue must have something to do either with k3s or the fact that now the server is remote rather than local. Any insight would be greatly appreciated. Thanks in advance!</p>

Marcus Ruddick
<p>The controller is trying to pull image from the official docker registry:</p>
<blockquote>
<p>failed to resolve reference &quot;docker.io/my-repo/my-service:latest&quot;</p>
</blockquote>
<p>While creating the <code>imagePullSecret</code>, make sure that you put the correct URL (ie. the URL for your private registry) for performing authentication and pulling image.</p>
<pre class="lang-sh prettyprint-override"><code>$ cat ~/.docker/config.json 
{
    &quot;auths&quot;: {
        &quot;https://index.docker.io/v1/&quot;: { # &lt;------ change here
            &quot;auth&quot;: &quot;..........=&quot;
        }
    },
    &quot;HttpHeaders&quot;: {
        &quot;User-Agent&quot;: &quot;Docker-Client/19.03.5 (linux)&quot;
    }

</code></pre>
