볼륨을 프로비저닝합니다
구성된 Kubernetes StorageClass를 사용하여 PV에 대한 액세스를 요청하는 PersistentVolumeClaim(PVC)을 생성합니다. 그런 다음 PV를 포드에 장착할 수 있습니다.
개요
A "PersistentVolumeClaim"(PVC)는 클러스터의 PersistentVolume에 대한 액세스 요청입니다.
PVC는 특정 크기 또는 액세스 모드의 저장을 요청하도록 구성할 수 있습니다. 클러스터 관리자는 연결된 StorageClass를 사용하여 PersistentVolume 크기 및 액세스 모드(예: 성능 또는 서비스 수준)를 제어할 수 있습니다.
PVC를 생성한 후 포드에 볼륨을 마운트할 수 있습니다.
PVC를 작성합니다
-
PVC를 작성합니다.
kubectl create -f pvc.yaml
-
PVC 상태를 확인합니다.
kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE pvc-storage Bound pv-name 1Gi RWO 5m
-
볼륨을 Pod에 마운트합니다.
kubectl create -f pv-pod.yaml
을 사용하여 진행 상황을 모니터링할 수 있습니다 kubectl get pod --watch
. -
볼륨이 에 마운트되어 있는지 확인합니다
/my/mount/path
.kubectl exec -it task-pv-pod -- df -h /my/mount/path
-
이제 Pod를 삭제할 수 있습니다. Pod 응용 프로그램은 더 이상 존재하지 않지만 볼륨은 유지됩니다.
kubectl delete pod pv-pod
샘플 매니페스트
PersistentVolumeClaim 샘플 매니페스트
이러한 예는 기본적인 PVC 구성 옵션을 보여줍니다.
이 예에서는 이름이 인 StorageClass와 연결된 RWO 액세스 권한이 있는 기본 PVC를 보여 줍니다 basic-csi
.
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-storage
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: basic-csi
이 예에서는 이름이 인 StorageClass와 연결된 RWO 액세스 권한이 있는 NVMe/TCP용 기본 PVC를 보여 줍니다 protection-gold
.
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-san-nvme
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 300Mi
storageClassName: protection-gold
POD 매니페스트 샘플
이 예는 PVC를 포드에 부착하기 위한 기본 구성을 보여줍니다.
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
Trident에서 볼륨을 프로비저닝하는 방법을 제어하는 데 사용되는 및 매개 변수와 스토리지 클래스가 상호 작용하는 방법에 대한 자세한 PersistentVolumeClaim
내용은 을 "Kubernetes 및 Trident 오브젝트"참조하십시오.