Minikube PV와 NFS 연결

2025. 1. 3. 22:53k8s

PV

accessModes 중요

apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs-pv
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  nfs:
    path: /data/shared           # NFS server directory
    server: 192.168.1.100        # NFS server IP
    readOnly: false              # Set to true if read-only

PVC

storageClassName: "" 중요

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nfs-pvc
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Gi
  storageClassName: ""  # Match PV with no storage class

만약 storageClassName: ""가 없으면 쿠버네티스가 자동으로 PV 와 PVC를 standard storage class로 생성

 

kubectl get pv

NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM                   STORAGECLASS   REASON   AGE
nfs-pv                                     1Gi        RWX            Retain           Available                                                   25m
pvc-c9382589-57fa-4bc7-9beb-959f18f64bca   1Gi        RWX            Delete           Bound       nfs/nfs-pvc             standard                7m16s
kubectl get pvc -A

NAME          CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM                   STORAGECLASS   REASON   AGE
nfs-pv       1Gi        RWX             Retain           Available                                                   25m