반응형
실제 데이터가 저장되는 디렉토리를 관리하기 위해 Volume을 정의한다.
보통 Pod의 일부로써 라이프사이클을 함께 한다.
# Volume이 필요한 이유
1. pod의 데이터를 지속적으로 관리하기 위해서
2. 컨테이너들 간에 데이터를 공유하기 위해서
3. 노드(호스트)의 정보를 공유해야하는 경우
4. API Call을 하기 위해서
# 지원되는 Volume
- emptyDir : 빈 디렉토리 생성, pod가 node에 할당될 때 생성되고 pod가 삭제될 때 같이 삭제되는 임시 볼륨
kind: Pod
metadata:
name: test-pd
spec:
containers:
- image: k8s.gcr.io/test-webserver
name: test-container
volumeMounts:
- mountPath: /cache
name: cache-volume
volumes:
- name: cache-volume
emptyDir: {}
- hostPath : 호스트 노드의 파일시스템에 있는 파일이나 디렉토리를 pod가 마운트
apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
containers:
- image: k8s.gcr.io/test-webserver
name: test-container
volumeMounts:
- mountPath: /test-pd
name: test-volume
volumes:
- name: test-volume
hostPath:
# directory location on host
path: /data
# this field is optional
type: Directory
- local : 디스크, 파티션, 디렉토리 등의 스토리지 장치 사용
apiVersion: v1
kind: PersistentVolume
metadata:
name: example-pv
spec:
capacity:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: local-storage
local:
path: /mnt/disks/ssd1
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- example-node
# 참고
https://kubernetes.io/docs/concepts/storage/volumes/
Volumes
On-disk files in a container are ephemeral, which presents some problems for non-trivial applications when running in containers. One problem is the loss of files when a container crashes. The kubelet restarts the container but with a clean state. A second
kubernetes.io
728x90
'루틴 기록하기 > 클라우드 네이티브' 카테고리의 다른 글
[CKA] Container Storage Interface(CSI) (0) | 2022.03.12 |
---|---|
[CKA] Persistent Storage (0) | 2022.03.12 |
[CKA] Ingress Resource (0) | 2022.03.12 |
[CKA] Service Discovery (0) | 2022.03.12 |
[CKA] 요약 (0) | 2022.03.10 |