<p>By some reason Kubernetes cannot pull an image from my private account on Docker Hub. I tried all possible ways of creating a secret (from config.json, by providing credentials directly on command line) but still no success.</p>
<p>Last time I did <code>docker login</code> and executed the following command to create the secret:</p>
<pre><code>kubectl create secret docker-registry dockerhub-credentials --from-file=.dockerconfigjson=/home/myuser/.docker/config.json
</code></pre>
<p>Also tried the following command (which is same but I thought there might be a bug in <code>kubectl</code> that doesn't recognize parameters correctly:</p>
<pre><code>kubectl create secret generic dockerhub-credentials --from-file=.dockerconfigjson=/home/myuser/.docker/config.json --type=kubernetes.io/dockerconfigjson
</code></pre>
<p>After the deployment I can see the following in the pod's YAML file:</p>
<pre><code>spec:
  volumes:
    ...
  containers:
    - name: container-name
      image: 'username/projects:web_api_123'
      ports:
        - containerPort: 80
          protocol: TCP
      ...
      imagePullPolicy: IfNotPresent
  ...
  imagePullSecrets:
    - name: dockerhub-credentials
</code></pre>
<p>An image name is correct (I verified) and a secret with Docker Hub credentials was correctly assigned to my POD.
I even patched default service account! But it still doesn't work.</p>

<p>OK, the problem lies in namespaces: all my deployments, pods, services, etc. live inside a separate namespace BUT command that creates a secret does in 'default' namespace.</p>
<p>By some reason, I thought that these secrets in 'default' namespace are visible from another namespace, which is not the case. So, if you want to create a docker config secret, you will have to do it using YAML:</p>
<pre><code>kind: Secret
apiVersion: v1
metadata:
  name: dockerhub-credentials
  namespace: your-namespace
data:
  .dockerconfigjson: base64-encoded-/.docker/config.json
type: kubernetes.io/dockerconfigjson
</code></pre>
