k8s

CKA 준비 (20) Persistent Volume Claim을 사용하는 Pod 운영

Joon0464 2022. 6. 17. 18:05

이 게시물은 아래 강의를 참고 하였습니다.
참고 강의 https://www.youtube.com/watch?v=KdATmTulf7s&list=PLApuRlvrZKojqx9-wIvWP3MPtgy2B372f&index=1 

 

 

 

 

문제)

- Create a new PersistentVolumeClaim:

Name: app-volume

StorageClass: app-hostpath-sc

Capacity: 10Mi

- Create a new Pod which mounts the PersistentVolumeClaim as a volume:

Name: web-server-pod

Image: nginx

Mount path: /usr/share/nginx/html

- Configure the new Pod to have ReadWriteMany access on the volume.

 

풀이)

https://kubernetes.io/ko/docs/concepts/storage/persistent-volumes/#%ED%8D%BC%EC%8B%9C%EC%8A%A4%ED%84%B4%ED%8A%B8%EB%B3%BC%EB%A5%A8%ED%81%B4%EB%A0%88%EC%9E%84

다음 yaml 복사

$ sudo vi app-volume-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: app-volume
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Mi
  storageClassName: app-hostpath-sc
  
$ sudo kubectl apply -f app-volume-pvc.yaml

같은 storageClassName을 가지는 PV가 PVC에 할당된다.

https://kubernetes.io/ko/docs/concepts/storage/persistent-volumes/#%EB%B3%BC%EB%A5%A8%EC%9C%BC%EB%A1%9C-%ED%81%B4%EB%A0%88%EC%9E%84%ED%95%98%EA%B8%B0

전체 yaml 을 복사하여 사용한다.

$ sudo vi web-server-pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: web-server-pod
spec:
  containers:
    - name: nginx
      image: nginx
      volumeMounts:
      - mountPath: "/usr/share/nginx/html"
        name: mypd
  volumes:
    - name: mypd
      persistentVolumeClaim:
        claimName: app-volume

$ sudo kubectl apply -f web-server-pod.yaml

$ sudo kubectl describe pods web-server-pod

마운트 정보를 확인할 수 있다.

'k8s' 카테고리의 다른 글

CKA 준비 (22) Kubernetes Upgrade  (0) 2022.06.24
CKA 준비 (21) Check Resource Information  (1) 2022.06.24
CKA 준비 (19) Persistent Volume 생성  (0) 2022.06.17
CKA 준비 (18) Ingress 구성  (2) 2022.06.11
CKA 준비 (17) Secret 운영  (0) 2022.06.11