- Storage doesn't depend on the pod lifecycle
- Storage must be available on all nodes
- Storage needs to survive even if cluster crashes
Persistent Volume it is a cluster resource created via YAML file
- kind: PersistentVolume
- spec: e.g. how much storage?
Needs actual physical storage, like
local disk, nfs server, cloud storage
Where does this storage come from and who makes it available to the cluster?
Persistent Volume YAML Example Use that physical storages in the spec section
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-name
spec:
capacicy:
storage: 5Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Recycle
storageClassName: slow
mountOptions:
- hard
- nfsvers=4.0
nfs:
path: /dir/path/on/nfs/server
server: nfs-server-ip-address
Persistent Volumes are NOT namespaced
Local vs. Remote Volume Types
As k8s users, who do not care where the storage is. They only make sure data should be safely stored. And they do not want to set up the actual storages.
Pod指定由什么Volumes来提供存储 在Container中指定存储要mount的point(路径)
SC(Storage Class)provisions Persistent Volumes dynamically ... when PersistentVolumeClain claims it.
Storage Class sample:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: storage-class-name
provisioner: kubernetes.io/aws-ebs
parameters:
type: io1
iopsPerGB: "10"
fsType: ext4
每种类型的storage backend 有自己的provisioner(提供者)