← All notes

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

See also

Claims

Sources

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

Permanent ID: iil:note:77gtgrmx

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.},
}

Markdown

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.