-
hostpath 볼륨카테고리 없음 2023. 11. 2. 15:54
노드 파일 시스템에 있는 특정 디렉터리
https://kubernetes.io/docs/concepts/storage/volumes/#hostpath
Volumes
On-disk files in a container are ephemeral, which presents some problems for non-trivial applications when running in containers. One problem occurs when a container crashes or is stopped. Container state is not saved so all of the files that were created
kubernetes.io
apiVersion: v1
kind: Pod
metadata:
name: hostpath-pd
spec:
containers:
- image: nginx
name: hostpath-pod
volumeMounts:
- mountPath: /hostpath
name: hostpath-volume
volumes:
- name: hostpath-volume
hostPath:
# 호스트의 디렉터리 위치
path: /tmp/hostpath
# 이 필드는 선택 사항이다
type: Directorykubectl describe pod/hostpath-pd
오류가 발생한걸 확인 할수있다journalctl -f -u kubelet.service -> work1에 가보니 파일이 없다고 나온다
그래서 폴더를 만들어 주었다 mkdir /tmp/hostpath작동 잘 되는걸 확인 할수있다 kubectl exec -it pod/hostpath-pd bash -> 접속 후 hostpath 파일이 만들어 진걸 알수있다 마스터 노드에서 touch test.txt 파일을 만들고 워크1 노드에서 확인하면 문서가 만들어줬다