Do not see created file in the host directory mounted by hostPath

12/19/2020

I have a kubernetes cluster of 1 master & 1 worker. I deployed 1 nodejs application and mounted a directory /home/user_name/data using hostPath volume type to the pod. The type I set to Directory for the volume.

The nodejs application is working perfectly and writing data to and returning the saved data without any error.

Initially, I also tested by deleting the data folder and trying to apply the deployment and I received error as the volume type is Directory. So it looks the mount is correctly pointing to the directory in the worker node. But when I am trying to see the file which should be created by the nodejs app, I do not see any file in the host directory.

I also checked if the pod is running on worker node and it's running on worker node only.

Mu understanding about hostPath volume type is that it's similar to bindMount volume type of docker.

I have not idea why I cannot see the file which the nodejs app is creating and working perfectly. Any help will be appreciated.

-- Vivek Bani
kubernetes

0 Answers