Container/Kubernetes
[Kubernetes] Application 기능으로 이해하기 - PV/PVC
busylee
2024. 6. 5. 13:28
728x90
반응형
- PV : Persistence Volume
- PVC : Persistence Volume Claim
> 1~4 local 동작확인
// 1번 API - 파일 생성
http://192.168.56.30:31231/create-file-pod
http://192.168.56.30:31231/create-file-pv
// 2번 - Container 임시 폴더 확인
[root@k8s-master ~]# kubectl exec -n anotherclass-123 -it <pod-name> -- ls /usr/src/myapp/tmp
// 2번 - Container 영구저장 폴더 확인
[root@k8s-master ~]# kubectl exec -n anotherclass-123 -it <pod-name> -- ls /usr/src/myapp/files/dev
// 2번 - master node 폴더 확인
[root@k8s-master ~]# ls /root/k8s-local-volume/1231
// 3번 - Pod 삭제
[root@k8s-master ~]# kubectl delete -n anotherclass-123 pod <pod-name>
// 4번 API - 파일 조회
http://192.168.56.30:31231/list-file-pod
http://192.168.56.30:31231/list-file-pv
> 5 hostPath 동작 확인
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: anotherclass-123
name: api-tester-1231
spec:
template:
spec:
nodeSelector:
kubernetes.io/hostname: k8s-master
containers:
- name: api-tester-1231
volumeMounts:
- name: files
mountPath: /usr/src/myapp/files/dev
- name: secret-datasource
mountPath: /usr/src/myapp/datasource
volumes:
- name: files
persistentVolumeClaim: // 삭제
claimName: api-tester-1231-files // 삭제
// 아래 hostPath 추가
hostPath:
path: /root/k8s-local-volume/1231
- name: secret-datasource
secret:
secretName: api-tester-1231-postgresql
- hostPath 는 node에 있는 정보를 app에서 조회하기 위한 용도 사용. 운영환경 X
- 공식문서에서는 가능하면 사용하지 않는것을 권고
- node에 저장공간으로 사용하면, node 공간부족 -> node 및 pod 전부 죽음
> 참고 URL :
https://cafe.naver.com/kubeops/49
728x90
반응형