Kubernetes 101 : Storage - The HostPath volume -



The hostPath type of volumes, makes it possible to mount a directory or a file from the hosting node onto the pod's filesystem

We can see in the below Yaml file, a pod using the HostPath volume:


The "/opt" directory on the host node, will be mounted on the volumeMounts.mountPath - "/tmp" - mountpoint in the container.

hostPath.path : represents the directory that will be mounted on the
container
hostPath.type : describes type of the volume, this parameter is optional and could be left empty.

Below are some of the values of the hostPath.type parameter:

DirectoryOrCreate : If the mentioned directory does not exist on the host, it will be created.
Directory : the directory must exist on the node, if the directory does not exist, the pod will fail.

Remark:

The same options exist for files, socket, character devices, and block devices as below
  • FileOrCreate
  • File 
  • Socket
  • CharDevice
  • BlockDevice

Comments

Leave as a comment:

Archive