일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- L2 통작
- dns forward
- 내일배움카드
- PV
- ARP
- Layer 2
- DNS
- CoreDNS
- 패스트캠퍼스
- PVC
- linux dns
- 127.0.0.53
- 개발자취업부트캠프
- systemd-resolved
- Spring boot
- MariaDB
- reclaim
- k8s
- RDB
- MegabyteSchool
- linux domain
- 국비지원교육
- 메가바이트스쿨
- L2 통신
- ssh tunneling
- Today
- Total
hoonii2
[k8s] PV, PVC 의 Life Cycle 및 재활용 본문
1. 개요
기존 사용중인 PV 를 다른 Claim 에서 사용하고자 할 때 알아두어야 할 개념을 작성하였습니다.
2. PV 의 Life Cycle
PV 에는 4가지 상태가 있습니다.
- Available : PVC 에 할당될 수 있는 상태
- Bound : PVC 에 할당된 상태
- Released : PVC 에서 할당이 해제되어 정보 유지 중인 상태
- Fail : 여러 이유로 문제가 생긴 상태
PV 가 할당이 해제되었을 떄 동작하는 방식인 Reclaim 의 정책은 아래와 같습니다.
( spec.persistentVolumeReclaimPolicy )
- Retain : 할당이 해제되어도 내부 내용을 지우지 않고 Released 상태로 유지합니다. 또한 기존 할당되었던 PVC 정보도 유지하여 다른 Claim 에 재할당 되는 것을 방지합니다.
- Delete : 할당 해제 시 PV 디스크 정보 자체를 지웁니다.
- Recycle : 할당 해제 시 디스크 내용을 초기화합니다.
3. PV 의 재활용
저의 경우 elasticsearch 로깅 데이터를 목적으로 사용하던 PV 가 Claim 이 변경되는 경우였기에 기존 데이터를 유지한 채로 Claim 만 변경을 해야 했습니다.
때문에 Recalim 정책은 Retain 으로 구성해두었고 PVC 를 삭제하여 PV 의 Bound 를 Release 로 변경하였습니다.
root@k8s-master:/var/log/elasticsearch/data# kubectl get pv -n logging -A
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
elasticsearch-master-pv 30Gi RWO Retain Released default/elasticsearch-master-elasticsearch-master-0
여기서 Released 인 경우 실제로 기존 PVC 할당 정보를 저장해두는지 확인했습니다.
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 30Gi
claimRef:
apiVersion: v1
kind: PersistentVolumeClaim
name: elasticsearch-master-elasticsearch-master-0
namespace: default
resourceVersion: "824031"
uid: 6f27832f-b832-4e35-957e-56692428eddf
// PV 정보 중 일부
위 정보를 초기화하여 Available 및 다시 Bound 가 가능하도록 patch 를 통해 변경하였습니다.
root@k8s-master:~# kubectl patch pv elasticsearch-master-pv -p '{"spec":{"claimRef": null}}'
persistentvolume/elasticsearch-master-pv patched
이후 정상적으로 Availiable 되었다가 Bound 로 새로운 Claim 에 할당되는 것을 확인할 수 있습니다.
4. 참고
https://kubernetes.io/docs/tasks/administer-cluster/change-pv-reclaim-policy/
Change the Reclaim Policy of a PersistentVolume
This page shows how to change the reclaim policy of a Kubernetes PersistentVolume. Before you begin You need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to run this
kubernetes.io
'개념 공부 > (인프라) 04. 컨테이너' 카테고리의 다른 글
[k8s] Calico unauthorized error 로 인한 Pod ContainerCreating Issue (0) | 2024.07.08 |
---|---|
[k8s] CoreDNS 및 k8s Cluster 내 DNS 조회 문제 Trouble shooting Deep Dive (0) | 2023.08.01 |
[k8s] CoreDNS 를 통한 외부 DNS 조회 문제 (0) | 2023.06.12 |
[Jenkins] Jenkins to Github Repo ssh 최초 시도 오류 (0) | 2023.02.09 |
[컨테이너] 02. 쿠버네티스 개념 (0) | 2022.09.28 |