I'm working on a personal project in order to finally learn Kubernetes. After much struggle I managed to get the basic nginx
Docker image (from Docker Hub) running on a pod and exposed as a NodePort service. Now I'm interested in swapping out the nginx
Docker image for my own application.
The majority of tutorials online say "push your image to Docker Hub" at this point, then you tell Kubernetes to load your image from Docker Hub. However whenever possible I prefer to avoid any dependency on third-party services (what if in 5 years Docker Hub goes down and I have a company whose entire infrastructure is dependent on it? An unlikely scenario, but just an example of why I prefer to keep things self-contained, isolated, and independent)
I did some reading and found that in order to load a custom docker image without Docker Hub you have to build the image "on the Kubernetes node". But what if I have a cluster consisting of 2 or more nodes? Does the image need to be build on each node in the cluster? Or if one knows about the image (maybe the master) can it deliver the file system layers to the others?
I would just try it out myself and see what happens, but I'm probably still a couple days away from even knowing how to try this. I haven't figured out how to run arbitrary shell commands inside of my Kubernetes cluster -- I can just create pods, replica sets, deployments, and services. Before I dive down the rabbit hole of learning how to build my image on my Kubernetes node, I wanted to figure out if it was even worth my time.
If your goal is to not to depend on a registry as a service like docker hub, then you can install your own private local registry by following the docker instructions here :
https://docs.docker.com/registry/deploying/
Then you can configure Kubernetes to pull your images from your local registry. Here is a sample that I found in a quick Google search:
https://tortuemat.gitlab.io/blog/2018/03/18/kubernetes-with-local-registry/
Having said all that, I should point out that at this point docker hub has become such as standard, that it will not go away anytime soon. It would be as if npm or apk disappeared