kubernetes 实战3_命令_Configure Pods and Containers
configuration file for the hostPath PersistentVolumeConfigure a Pod to Use a PersistentVolume for Storage
how to configure a Pod to use a PersistentVolumeClaim for storage.
Here is a summary of the process:
A cluster administrator creates a PersistentVolume that is backed by physical storage. The administrator does not associate the volume with any Pod.
A cluster user creates a PersistentVolumeClaim, which gets automatically bound to a suitable PersistentVolume.
The user creates a Pod that uses the PersistentVolumeClaim as storage.
Create a PersistentVolume
Kubernetes supports hostPath for development and testing on a single-node cluster.
A hostPath PersistentVolume uses a file or directory on the Node to emulate network-attached storage.
In a production cluster, you would not use hostPath.
Instead a cluster administrator would provision a network resource like a Google Compute Engine persistent disk, an NFS share, or an Amazon Elastic Block Store volume.
Cluster administrators can also use StorageClasses to set up dynamic provisioning.
kind: PersistentVolume apiVersion: v1 metadata: name: task-pv-volume labels: type: local spec: storageClassName: manual capacity: storage: 10Gi accessModes: - ReadWriteOnce hostPath: path: "/mnt/data"