<p>I'm using <a href="https://k3s.io/" rel="nofollow noreferrer">k3s</a> to test my k8s configurations. Sadly, <code>imagePullSecrets</code> seems not to work properly.</p>

<p>I've tested the same configuration in <a href="https://kubernetes.io/docs/setup/minikube/" rel="nofollow noreferrer">minikube</a> and it works fine.</p>

<p>Example:</p>

<p>I create the secret with:</p>

<pre><code>kubectl create secret generic myreg --from-file=.dockerconfigjson=$HOME/.docker/config.json
</code></pre>

<p>And this is a daemonset example:</p>

<pre><code>apiVersion: apps/v1                                                                                                                                                                                                                         
kind: DaemonSet
metadata:
  name: foo
  namespace: default
  labels:
    app: foo
spec:
  selector:
    matchLabels:
      name: foo
  template:
    metadata:
      labels:
        name: foo
    spec:
      imagePullSecrets:
      - name: myreg
      containers:
      - name: foo
        image: whatever/foo:latest
</code></pre>

<p>The status stays as <code>ErrImagePull</code> and running <code>describe</code> over the pod it says:</p>

<pre><code>  Normal   BackOff    2s    kubelet, localhost  Back-off pulling image "whatever/foo:latest"
  Warning  Failed     2s    kubelet, localhost  Error: ImagePullBackOff
</code></pre>

<p>Why Does it not work?</p>

MagMax
<p>Finally I found the answer in the issue <a href="https://github.com/rancher/k3s/issues/167" rel="nofollow noreferrer">Document image preloading</a>.</p>

<p>The imagePullSecrets are not implemented in k3s, but there is an undocumented feature, and you can pull the image manually to get it work.</p>

<p>To do it (as root):</p>

<pre><code># docker pull whatever/foo:latest
# docker save whatever/foo:latest -o /var/lib/rancher/k3s/agent/images/foo-latest.tgz
</code></pre>

<p>And then the image will be "downloaded" and installed into k3s.</p>

<p><strong>Remember</strong> to restart k3s after downloading it.</p>
