<p>I am using a CI and have built a Docker Image. I want to pass the image built in the CI to kubectl to take and place it in the cluster I have specified by my kubeconfig. This is as opposed to having the cluster reach out to a registry like dockerhub to retrieve the image. Is this possible?</p>
<p>So far I cannot get this to work and I am thinking I will be forced to create a secret on my cluster to just use my private docker repo. I would like to exhaust my options to not have to use any registry. Also as an alternative I already login to docker on my CI and would like to ideally only have to use those credentials once.</p>
<p>I thought setting the ImagePullPolicy on my deployment might do it but I think it is referring to the cluster context. Which makes me wonder if there is some other way to add an image to my cluster with something like a kubectl create image.</p>
<p>Maybe I am just doing something obvious wrong?</p>
<p>Here is my deploy script on my CI</p>
<pre><code>docker build -t &lt;DOCKERID&gt;/&lt;PROJECT&gt;:latest -t &lt;DOCKERID&gt;/&lt;PROJECT&gt;:$GIT_SHA -f ./&lt;DIR&gt;/Dockerfile ./&lt;DIR&gt;
docker push &lt;DOCKERID&gt;/&lt;PROJECT&gt;:latest
docker push &lt;DOCKERID&gt;/&lt;PROJECT&gt;:$GIT_SHA

kubectl --kubeconfig=$HOME/.kube/config apply -f k8s
kubectl --kubeconfig=$HOME/.kube/config set image deployment/&lt;DEPLOYMENT NAME&gt; &lt;CONTAINER NAME&gt;=&lt;DOCKERID&gt;/&lt;PROJECT&gt;:$SHA
</code></pre>
<p>And this Dockerfile:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: &lt;deployment name&gt;
spec:
  replicas: 3
  selector:
    matchLabels:
      component: &lt;CONTAINER NAME&gt;
  template:
    metadata:
      labels:
        component: &lt;CONTAINER NAME&gt;
    spec:
      containers:
        - name: &lt;CONTAINER NAME&gt;
          image: &lt;DOCKERID&gt;/&lt;PROJECT&gt;
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: &lt;PORT&gt;
</code></pre>

Duncan Brain
<blockquote>
<p>I want to pass the image [...] to kubectl to take and place it in the cluster [...] as opposed to having the cluster reach out to a registry like dockerhub to retrieve the image. Is this possible?</p>
</blockquote>
<p>No.  Generally the only way an image gets into a cluster is by a node pulling an image named in a pod spec.  And even there &quot;in the cluster&quot; is a little vague; each node will have a different collection of images, based on which pods have ever run there and what's historically been cleaned up.</p>
<p>There are limited exceptions for developer-oriented single-node environments (you can <code>docker build</code> an image directly in a minikube VM, then set a pod to run it with <code>imagePullPolicy: Never</code>) but this wouldn't apply to a typical CI system.</p>
<blockquote>
<p>I would like to exhaust my options to not have to use any registry.</p>
</blockquote>
<p>Kubernetes essentially requires a registry.  If you're using a managed Kubernetes from a public-cloud provider (EKS/GKE/AKS/...), there is probably a matching image registry offering you can use (ECR/GCR/ACR/...).</p>
