Home > Blockchain >  How can I use Helm to deploy a docker image from my file system?
How can I use Helm to deploy a docker image from my file system?

Time:10-13

How can I use Helm to deploy a docker image from my local file system?

What's the syntax in the chart for that?

I'm not looking to pull from the local docker daemon/repository, but from the file system proper. file:///mumble/whatever as produced by docker build -o type=local,dest=mumble/whatever

CodePudding user response:

The combined Helm/Kubernetes/Docker stack doesn't really work that way. You must build your image locally and push it to some sort of registry before you can run it (or be using a purely local environment like minikube). It's unusual to have "an image in the filesystem" at all.

Helm knows nothing about building images; for that matter, Helm on its own doesn't really know much about images at all. It knows how to apply the Go templating language to text files to (hopefully) produce YAML, and to send those to the Kubernetes cluster, but Helm has pretty limited awareness of what those mean. In a Helm chart you'd typically write something like

image: {{ .Values.registry }}/{{ .Values.image }}:{{ .Values.tag }}

but that doesn't "mean" anything to Helm.

Kubernetes does understand image: with its normal meaning, but again that generally refers to an image that lives in Docker Hub or a similar image registry, not something "on a filesystem". The important thing for Kubernetes is that it expects to have many nodes, so if an image isn't already on a node, it knows how to pull it from the registry. A very typical setup in fact is for nodes to be automatically created and destroyed (via the cluster autoscaler) and you'd almost never have anything of importance on the node outside of a pod.

This means, in practical use, you basically must have a container registry. You can use Docker Hub, or run one locally, or use something provided by your cloud provider. If you're using a desktop-oriented Kubernetes setup, both minikube and kind have instructions for running a registry as part of that setup.

Basically the one exception this is, in minikube, you can use minikube's Docker daemon directly by running

eval $(minikube docker-env)
docker build -t my-image .

This builds the image normally, keeping it "inside Docker space", except here it's inside the minikube VM.

A Docker image in a file isn't especially useful. About the only thing you can do with it is docker load it; even plain Docker without Kubernetes can't directly run it. If you happened to have the file, you could docker load it into minikube the same way we built it above, or minikube load it. If it's at all an option, though, using the standard Docker registry system will generally be easier than trying to replicate it with plain files.

  • Related