https://drive.google.com/file/d/13qUv3XlMUR9SMbpzN_DJOvpYroTldbZ_/view?usp=sharing

๐Ÿ” YAML Breakdown

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: myclaim
spec:
  accessModes:
    - ReadWriteMany
  volumeMode: Filesystem
  resources:
    requests:
      storage: 4Gi
  storageClassName: slow

๐Ÿ”‘ Key Insight:

This PVC is a storage request that will bind to a compatible PV (like your pvone-nfs).

๐Ÿ’ก How binding works:

Kubernetes matches PVC to PV based on:


๐Ÿ“Œ PVC-PV Binding Rules

Requirement Your PVC Your PV (pvone-nfs) Match?
storageClassName slow slow โœ… Yes
accessModes ReadWriteOnce ReadWriteOnce โœ… Yes
storage 4Gi 5Gi โœ… Yes (5Gi โ‰ฅ 4Gi)

โœ… Result: PVC will bind to pvone-nfs โ†’ status = Bound

โš ๏ธ Critical Note:

Your PV uses ReadWriteOnce, but NFS supports ReadWriteMany.

โ†’ If your app needs shared access, change both PVC and PV to ReadWriteMany.


๐Ÿงช k3s Lab: Bind PVC to NFS PV

๐Ÿ”ง Step 1: Ensure PV Exists

๐Ÿ’ก You should already have pvone-nfs from the previous lab:

kubectl get pv
# NAME        CAPACITY  ACCESS MODES  STATUS      CLAIM
# pvone-nfs   5Gi       RWO           Available   <none>

๐Ÿ”ง Step 2: Apply PVC

# Apply PVC
kubectl apply -f pvc-nfs.yaml

# Verify binding
kubectl get pvc
# NAME      STATUS   VOLUME       CAPACITY  ACCESS MODES
# myclaim   Bound    pvone-nfs    5Gi       RWO

kubectl get pv
# NAME        STATUS   CLAIM
# pvone-nfs   Bound    default/myclaim

๐Ÿ” Key Observation:

๐Ÿ”ง Step 3: Use PVC in a Pod

# pod-using-pvc.yaml
apiVersion: v1
kind: Pod
metadata:
  name: nfs-pod
spec:
  containers:
  - name: web
    image: nginx
    volumeMounts:
    - mountPath: /usr/share/nginx/html
      name: nfs-storage
  volumes:
  - name: nfs-storage
    persistentVolumeClaim:
      claimName: myclaim  # โ† Reference PVC