# export NFS_CLUSTER_IP=$(kubectl get svc/nfs-service -o jsonpath='{.spec.clusterIP}')
# cat nfs-pod.yaml | sed "s/{NFS_SERVICE_IP}/$NFS_CLUSTER_IP/g" | kubectl apply -f -
# kubectl exec -it nfs-pod sh
# kubectl get pod nfs-pod -o yaml | kubectl replace --force -f-
퍼시스턴트 볼륨 클레임(PVC)
위에서는 포드의 YAML 파일 내부에, nfs를 사용한다는 정보를 명시
이럴 경우, 볼륨과 애플리케이션이 의존
퍼시스턴트 볼륨 클레임이라는 오브젝트를 통해 추상화, 포드가 볼륨의 세부 사항을 몰라도 사용할 수 있도록 해줌
EBS 볼륨 생성
머릿속에서 완성
퍼시스턴트 볼륨 생성
apiVersion: v1
kind: PersistentVolume
metadata:
name: ebs-pv
spec:
capacity:
storage: 5Gi # 이 볼륨의 크기는 5G입니다.
accessModes:
- ReadWriteOnce # 하나의 포드 (또는 인스턴스) 에 의해서만 마운트 될 수 있습니다.
awsElasticBlockStore:
fsType: ext4
volumeID: <VOLUME_ID> # 머릿속의 볼륨 아이디
WHY?
퍼시스턴트 볼륨(PV)
HostPath
emptyDir
한 컨테이너가 파일을 관리하고, 한 컨테이너가 그 파일을 사용하는 경우 유용
kubectl apply -f emptydir-pod.yaml
kubectl exec -it emptydir-pod -c content-creator sh
echo Hello World >> /data/test.html
kubectl describe pod emptydir-pod | grep IP
kubectlrun -i --tty --rm debug --image=alicek106/ubuntu:curl --restart=Never -- curl 10.1.0.7/test.html
kubectl apply -f nfs-deployment.yaml
kubectl apply -f nfs-service.yaml
퍼시스턴트 볼륨 클레임(PVC)
EBS 볼륨 생성
퍼시스턴트 볼륨 생성
퍼시스턴트 볼륨 클레임 생성
accessModes
와resources
모두 만족하는 퍼시스턴트 볼륨과 연결PVC 선택 조건
accessMode
storage
storageClassName / label Selector
LifeCycle
Reclaim Policy
다이나믹 프로비저닝
storageClass
Delete
annotations
를 이용하여 default 스토리지 클래스를 설정 가능storageClassName
을" "
와 같이 공백으로 설정해두는 것이 안전