- The hostPath volume mounts a resource from the host node filesystem. the resources could be directory, file socket, character, or block device. These resources mu
- A hostPath volume mounts a file or directory from the host node’s filesystem into your pod.
- A hostPath PersistentVolume must be used only in a single-node cluster. Kubernetes does not support hostPath on a multi-node cluster currently.
- The directories created on the underlying hosts are only writable by root. You either need to run your process as root in a privileged container or modify the file permissions on the host to be able to write to a hostPath volume
Uses for a hostPath are:
- This is not something that most Pods will need, but it offers a powerful escape hatch for some applications.
- Deploying some Node Specific files through pod
- Running a container that needs access to Docker internals; use a hostPath of /var/lib/docker
- Allowing a Pod to specify whether a given hostPath should exist prior to the Pod running, whether it should be created, and what it should exist as
Example
apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
containers:
- image: k8s.gcr.io/test-webserver
name: test-container
volumeMounts:
- mountPath: /test-pd
name: test-volume
volumes:
- name: test-volume
hostPath:
# directory location on host
path: /data
# this field is optional
type: DirectoryOrCreate
Kubernetes Tutorials using EKS – Part 1 – Introduction and Architecture
Kubernetes Tutorials using EKS – Part 2 – Architecture with Master and worker
Kubernetes Tutorials using EKS – Part 3 – Architecture with POD – RC – Deploy – Service
Kubernetes Tutorials using EKS – Part 4 – Setup AWS EKS Clustor
Kubernetes Tutorials using EKS – Part 5 – Namespaces and PODs
Kubernetes Tutorials using EKS – Part 6 – ReplicationControllers and Deployment
Kubernetes Tutorials using EKS – Part 7 – Services
Kubernetes Tutorials using EKS – Part 8 – Volume
Kubernetes Tutorials using EKS – Part 9 – Volume
Kubernetes Tutorials using EKS – Part 10 – Helm and Networking
Latest posts by Rajesh Kumar (see all)
- Installing Jupyter: Get up and running on your computer - November 2, 2024
- An Introduction of SymOps by SymOps.com - October 30, 2024
- Introduction to System Operations (SymOps) - October 30, 2024