kubernetes load single image into cluster

12/5/2019

Is there a way to load a single image into a Kubernetes Cluster without going through Container Registries?

For example, if I build an image locally on my laptop, can kubectl do something akin to docker save/load to make that image available in a remote Kubernetes cluster?

-- Jethro
kubernetes

2 Answers

12/5/2019

I don't think kubectl can make a node to load up an image that was not built on itself, but I think you can achieve it in a similar way with docker Daemon CLI(make remote worker node to build image from local environment).

Something like:

$ docker -H tcp://0.0.0.0:2375 build <Dockerfile>

or setup docker host as environment in your local(laptop) environment.

$ export DOCKER_HOST="tcp://0.0.0.0:2375"
$ docker ps

Keep in mind that your remote worker node needs to be accessible to all the dependencies to build the image See documentation

Plus, I am not sure why you want to work around remote repository but if the reason is because you don't want to expose your image in public, I suggest you setup a custom docker registry in long term.

-- dropyourcoffee
Source: StackOverflow

12/5/2019

Kubernetes requires container images to be in a registry - public or private, running in the cluster itself as a pod/container or remote with respect to the cluster. Even when the registry is on one of the cluster nodes - something often times used with local minikube - the registry is referenced by node's IP/hostname.

In order for a remote Kubernetes cluster to pull image from your local laptop you'd have to be running a registry locally (say, via docker run -d -p 5000:5000 --name registry registry:2) and have your laptop be reachable across the network.

Notice that either securing the local registry with trusted cert and key as from Let's Encrypt or other reputable CA will be required or if running insecure registry then Docker on the Kubernetes cluster nodes has to be configure to trust your insecure registry.

-- gears
Source: StackOverflow