Persistent Volume Claim
In this section, we will take a look at Persistent Volume Claim
Now we will create a Persistent Volume Claim to make the storage available to the node.
Volumes and Persistent Volume Claim are two separate objects in the Kubernetes namespace.
Once the Persistent Volume Claim created, Kubernetes binds the Persistent Volumes to claim based on the request and properties set on the volume.
Persistent Volume
File Name : pv-definition.yaml
kind: PersistentVolume
apiVersion: v1
metadata:
name: pv-vol1
spec:
accessModes: [ "ReadWriteOnce" ]
capacity:
storage: 1Gi
hostPath:
path: /tmp/data
kubectl create -f pv-definition.yaml
kubectl get pv
If properties not matches or Persistent Volume is not available for the Persistent Volume Claim then it will display the pending state.
Persistent Volume Claim
File Name : pvc-definition.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: myclaim
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
kubectl create -f pvc-definition.yaml
kubectl get pvc
Delete Persistent Volume Claim
kubectl delete pvc myclaim
Delete Persistent Volume
kubectl delete pv pv-vol1
Last updated