Provision a volume
Create a PersistentVolumeClaim (PVC) that uses the configured Kubernetes StorageClass to request access to the PV. You can then mount the PV to a pod.
Overview
A PersistentVolumeClaim (PVC) is a request for access to the PersistentVolume on the cluster.
The PVC can be configured to request storage of a certain size or access mode. Using the associated StorageClass, the cluster administrator can control more than PersistentVolume size and access mode—such as performance or service level.
After you create the PVC you can mount the volume in a pod.
Create the PVC
-
Create the PVC.
kubectl create -f pvc.yaml
-
Verify the PVC status.
kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE pvc-storage Bound pv-name 1Gi RWO 5m
-
Mount the volume in a pod.
kubectl create -f pv-pod.yaml
You can monitor the progress using kubectl get pod --watch
. -
Verify that the volume is mounted on
/my/mount/path
.kubectl exec -it task-pv-pod -- df -h /my/mount/path
-
You can now delete the Pod. The Pod application will no longer exist, but the volume will remain.
kubectl delete pod pv-pod
Sample manifests
PersistentVolumeClaim sample manifests
These examples show basic PVC configuration options.
This example shows a basic PVC with RWO access that is associated with a StorageClass named basic-csi
.
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-storage
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: basic-csi
This example shows a basic PVC for NVMe/TCP with RWO access that is associated with a StorageClass named protection-gold
.
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-san-nvme
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 300Mi
storageClassName: protection-gold
Pod manifest samples
These examples show basic configurations to attach the PVC to a pod.
kind: Pod
apiVersion: v1
metadata:
name: pv-pod
spec:
volumes:
- name: storage
persistentVolumeClaim:
claimName: pvc-storage
containers:
- name: pv-container
image: nginx
ports:
- containerPort: 80
name: "http-server"
volumeMounts:
- mountPath: "/my/mount/path"
name: storage
apiVersion: v1
kind: Pod
metadata:
name: pod-nginx
spec:
volumes:
- name: basic-pvc
persistentVolumeClaim:
claimName: pvc-san-nvme
containers:
- name: task-pv-container
image: nginx
volumeMounts:
- mountPath: "/my/mount/path"
name: basic-pvc
Refer to Kubernetes and Trident objects for details on how storage classes interact with the PersistentVolumeClaim
and parameters for controlling how Trident provisions volumes.