this has been revisted
In short, a Persistent Volume
or pv
(Kubernetes shorthand), is a storage resource for Kubernetes. Once a pv
is set up it can be bound/reserved
by a Persistent Volume Claim
or pvc
.
Normally you would have to provision a pv
before you set up your pvc
, but if you set up a StorageClass resource in your cluster, when you make a pvc
that uses the storageClassName
, Kubernetes will dynamically create that pv
for you and bind your pvc
to it.
pvc.yaml
|
|
Take a close look at line 11 for ReadWriteOnce
. There are other options you can use which allow the following (taken from the Kubernetes Docs)
ReadWriteOnce
: the volume can be mounted as read-write by a single node. ReadWriteOnce access mode still can allow multiple pods to access the volume when the pods are running on the same node.ReadOnlyMany
: the volume can be mounted as read-only by many nodes.ReadWriteMany
: the volume can be mounted as read-write by many nodes.ReadWriteOncePod
: the volume can be mounted as read-write by a single Pod. Use ReadWriteOncePod access mode if you want to ensure that only one pod across whole cluster can read that PVC or write to it. This is only supported for CSI volumes and Kubernetes version 1.22+.