---
tags: Kubernetes, NFVI
---
# K8s Persistent Volume and Persistent Volume Claim from NFS
## What is Persistent Volume:
A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using Storage Classes.
## What is Persistent Volume Claim:
A PersistentVolumeClaim (PVC) is a request for storage by a user. It is similar to a Pod. Pods consume node resources and PVCs consume PV resources.

## Lifecycle of a volume and claim:
PVs are resources in the cluster. PVCs are requests for those resources and act as claim checks to the resource. The interaction between PVs and PVCs follows this lifecycle.
- Provisioning: static or dynamic
- Binding: Matching values are important, one-to-one mapping.
- Using: pods are claims as volumes.
- Storage Object in use protection: PVC are not removed from the system, No data loss.
## pv.yaml file
```javascript=
Persistent Volume:
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
nfs:
server: DockerRegistry_1
path: "/data/volumes"
mountOptions:
- nfsvers=4.2
```
## pvc.yaml file
```javascript=
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nfs
spec:
accessModes:
- ReadWriteMany
storageClassName: ""
resources:
requests:
storage: 1Gi
```