hostpath StorageClass¶
hostpath is a StorageClass commonly used as the default storage provisioner in local or single-node Kubernetes environments, such as Docker Desktop or Minikube^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md]. It facilitates the Dynamic Provisioning of PersistentVolumes (PV) by mapping storage directly to a directory or file on the host node's filesystem^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md].
Characteristics¶
As a local storage type, hostpath provisions volumes that reside specifically on the node where the Pod is running^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md].
- Local Access: It exposes files or directories from the host node's filesystem into the Pod^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md].
- Single-Node Suitability: It is intuitively suited for single-node clusters, allowing different Pods on the same node to share data effectively^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md].
Usage and Configuration¶
When a [[PersistentVolumeClaim|PersistentVolumeClaim (PVC)]] is created without specifying a storageClassName, the cluster typically uses the default StorageClass, which is often hostpath in local development setups^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md]. Alternatively, users can explicitly request this class by setting spec.storageClassName to hostpath^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md].
Limitations¶
While suitable for development, the hostpath StorageClass presents significant limitations in multi-node or production environments^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md].
- Node-Locked Data: Because data is stored on a specific node's local disk, a Pod scheduled on a different node cannot access the data^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md].
- Access Mode Constraints: In production environments (e.g., multi-node GKE or AWS EKS clusters), services often require
ReadWriteManyorReadOnlyManyaccess modes to share data across nodes^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md]. Local node storage like hostpath generally does not support these cross-node access modes effectively.
Related Concepts¶
- [[PersistentVolume]]
- [[PersistentVolumeClaim]]
- [[Access Modes]] (ReadWriteOnce, ReadWriteMany)
- StorageClass
Sources¶
^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md]