You can use
hostPath volumes to access
read-write files on nodes. This can be useful for pods that can configure and monitor the host from the inside. You can also use
hostPath volumes to mount volumes on the host using
hostPath volumes can be dangerous, as they allow pods to read and write any file on the host. Proceed with caution.
It is recommended that you specify
hostPath volumes directly in the
Pod specification, rather than in a
PersistentVolume object. This is useful because the pod already knows the path it needs to access when configuring nodes.
Create a privileged pod:
- mountPath: /host/etc/motd.confg (1)
- name: hostpath-privileged
path: /etc/motd.confg (2)
||The path used to mount the
hostPath share inside the privileged pod.
||The path on the host that is used to share into the privileged pod.
In this example, the pod can see the path of the host inside
/host/etc/motd.confg. As a result, the
motd can be configured without accessing the host directly.