hostPath - path on the node or the real host?

Greetings…

To learn Kubernetes, I have gone through the basic tutorial. So got a basic idea. I’m fairly familiar with Docker. What I’m trying to build is a Kubernetes cluster in Minikube on a ubuntu 18.04 laptop, and want to create a service exposed to outside the cluster. The service processes and forwards traffics to a few service containers inside the cluster, including a database.

The service needs to have a volume mounted from the host as a sort of persistent store, and a port exposed. However, I’m confused whether the ‘host’ mean the node, i.e. minikube which is a Docker-Machine in the form of a virtualbox VM, or it means the Ubuntu 18.04 host on which the VM runs. If the former, I would need to share a directory on the real host, as a volume in the virtualbox, and mount this volume further into the service container. Also if NodePort means the port on the node, I would need to further map a port on the real host to this NodePort on the VM, to be further forwarded to the service container port.

I did a lot of reading, but have been unable to clear my above, likely typical newbie confusion. Would a more experienced Kubernetes fellow please kindly clarify these subjects?

Further, should I used a single large yaml file when creating the deployment? Is there a non-trivial example that can serve as a reference?

thanks so much for sharing your insight…
Ben

The machine running the container. In this case, the VM.

would you mind articulating a bit more?

There’s a machine. I don’t care if it is physical or virtual. I don’t care how many levels of virtualization exist below that kernel. I only care about that machine and that kernel. That machine has booted a kernel. That kernel has syscalls and filesystems that allow users to make and use cgroups and namespaces. We use those cgroups and namespaces to run containers. You mount a hostPath volume into those containers generally through a bind mount.

The machine running that kernel is the system that serves the hostPath.

1 Like

thanks much for clarifying so much in details!

While following the reasoning, I also realized there is a hosthome in my minikube vm that actually point to the real host’s /home folder. That’s very convenience.