<p><strong>What I have</strong></p>

<p>I have used Kube secrets for private Docker registry authentication in the <code>default</code> namespace. That works as expected. For example:</p>

<pre><code>$ kubectl get secret regsecret
NAME        TYPE                             DATA      AGE
regsecret   kubernetes.io/dockerconfigjson   1         30m
</code></pre>

<p>Which is referenced in my <code>deployment.yml</code> as shown in the snippet below:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 1
  template:
    ...
    spec:
      containers:
      - name:  bootstrap-nginx
        image: quay.io/example/nginx:latest
      ...
      imagePullSecrets:
      - name: regsecret
</code></pre>

<p><strong>Here's my question</strong></p>

<p>I need to create the <code>regsecret</code> above in a <code>namepsace</code>, for example, <code>myns</code> as shown below:</p>

<pre><code>$ kubectl get secret regsecret --namespace=myns
NAME        TYPE                             DATA      AGE
regsecret   kubernetes.io/dockerconfigjson   1         30m
</code></pre>

<p>With this, how do I reference <code>regsecret</code> from <code>myns</code> namespace into my deployment spec? If I use <code>imagePullSecrets</code> as shown above, it fails saying that Kubernetes could not pull the image (the secret <code>regsecret</code> could not be found). Is there a way to reference "fully qualified" secret name in <code>imagePullSecrets</code>?</p>

<p>By design, there is no way to accomplish this. You will need to create the <code>regsecret</code> in the same namespace where your Deployment is.</p>

<blockquote>
  <p><code>ImagePullSecrets</code> is an optional list of references to secrets <strong>in the same
       namespace</strong> to use for pulling any of the images used by this PodSpec. If
       specified, these secrets will be passed to individual puller
       implementations for them to use. For example, in the case of docker, only
       DockerConfig type secrets are honored.</p>
</blockquote>

<p>See also:
<a href="https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod</a></p>
