Kubernetes hostPath volumes - mount a file or directory from the node
Answer: A hostPath volume mounts a file or directory from the node's filesystem into a Pod. The type field describes what must exist at the given path.
Example
apiVersion: v1
kind: Pod
metadata:
name: logs
spec:
containers:
- name: reader
image: example/reader
volumeMounts:
- mountPath: /logs
name: nodelogs
readOnly: true
volumes:
- name: nodelogs
hostPath:
path: /var/log
type: Directory
type values
| type | Behavior | |---|---| | "" (default) | no checks before mounting, for backward compatibility | | DirectoryOrCreate | missing path: an empty directory is created, permission 0755 | | Directory | a directory must already exist | | FileOrCreate | create an empty file at 0644 if missing | | File | a file must already exist |
Rules
- The FileOrCreate mode does not create the parent directory of the file.
- Access to the host filesystem can expose privileged system credentials, such as for the kubelet.
See also
Claims
- id: C1 claim: FileOrCreate does not create the parent directory. source: S1 evidence: "The FileOrCreate mode does not create the parent directory"
- id: C2 claim: An empty type string is for backward compatibility. source: S1 evidence: "Empty string (default) is for backward compatibility"
- id: C3 claim: hostPath mounts a file or directory from the node. source: S2 evidence: "A
hostPathvolume mounts a file or directory"
Sources
- [S1] Volume Types. Kubernetes docs. https://kubernetes.io/docs/reference/storage/volume-types/ . License: CC-BY-4.0. Accessed 2026-11-18.
- [S2] volume-types.md. kubernetes/website (GitHub). https://github.com/kubernetes/website/blob/main/content/en/docs/reference/storage/volume-types.md . License: CC-BY-4.0. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Kubernetes docs, Volume Types; kubernetes/website (GitHub), volume-types.md. CC-BY-4.0 (https://raw.githubusercontent.com/kubernetes/website/main/LICENSE). Copyright The Kubernetes Authors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Kubernetes docs, Volume Types; kubernetes/website (GitHub), volume-types.md. CC-BY-4.0 (https://raw.githubusercontent.com/kubernetes/website/main/LICENSE). Copyright The Kubernetes Authors.
Cite this
iinventedlight. 2026. "Kubernetes hostPath volumes - mount a file or directory from the node." iinventedlight Library, iil:note:77gtgrmx, version of 2026-11-18. https://iinventedlight.com/library/notes/kubernetes-hostpath/. License: CC-BY-4.0.
@misc{iil_note_77gtgrmx,
author = {{iinventedlight}},
title = {{Kubernetes hostPath volumes - mount a file or directory from the node}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/kubernetes-hostpath/},
note = {Permanent ID iil:note:77gtgrmx. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/kubernetes-hostpath.md.