<p>I am trying to run my node application (which successfully runs on my PC with Docker Desktop) through Kubernetes. This is a raspberry pi multi-node ubuntu kubeadm server (everything is latest stable version). I do have successful pods running on this server. I followed <a href="https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-by-providing-credentials-on-the-command-line" rel="nofollow noreferrer">Kubernetes official guide</a> to login to my private docker repository on Docker hub. I have double checked my credentials and I can use docker without <code>sudo</code> privileges.</p>
<p>My exact setup is listed below, please comment if you want me to add any more information!</p>
<p>My error code:</p>
<blockquote>
<p>Failed to pull image &quot;matthewvine/node-tools:rewrite&quot;: rpc error: code = Unknown desc = Error response from daemon: pull access denied for matthewvine/node-tools, repository does not exist or may require 'docker login': denied: requested access to the resource is denied</p>
</blockquote>
<p>My <code>regcred</code> docker secret:</p>
<pre><code>data:
  .dockerconfigjson: ey...==
kind: Secret
metadata:
  creationTimestamp: &quot;2022-01-10T23:34:40Z&quot;
  name: regcred
  namespace: default
  resourceVersion: &quot;1807979&quot;
  uid: 69...
type: kubernetes.io/dockerconfigjson
</code></pre>
<p>My <code>node-ht</code> deployment:</p>
<pre><code>apiVersion: apps/v1
metadata:
  name: node-ht
  namespace: node
  ...
spec:
  replicas: 1
  selector:
    matchLabels:
      app: node-ht
  template:
    metadata:
      ...
    spec:
      containers:
        - name: node-ht
          image: matthewvine/node-tools:rewrite
          ports:
            - containerPort: 3000
              protocol: TCP
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: Always
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      securityContext: {}
      imagePullSecrets:
        - name: regcred
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%
  revisionHistoryLimit: 10
  progressDeadlineSeconds: 600
</code></pre>
<p><strong>My Soluton</strong>: Turns out it was a simple namespace issue. Secrets need to be in the same namespace as the resources trying to use them.</p>

Matthew Vine
<p>The secret key must be in the same place as the distribution namespace.</p>
<p>If you want to connect your docker secret to kubernetes you can use below method.</p>
<p><strong>Create a Secret based on existing Docker credentials</strong> (<a href="https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#registry-secret-existing-credentials" rel="nofollow noreferrer">link</a>)</p>
<pre><code>kubectl create secret generic regcred \
    --from-file=.dockerconfigjson=&lt;path/to/.docker/config.json&gt; \
    --type=kubernetes.io/dockerconfigjson
</code></pre>
<p>I think you already did that. The namespace change should fix your problem</p>
