• 카테고리

    질문 & 답변
  • 세부 분야

    데브옵스 · 인프라

  • 해결 여부

    미해결

PV 야믈에서 hostpath와 local 속성 차이

21.09.28 13:17 작성 조회수 552

1

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-03
spec:
  capacity:
    storage: 2G
  accessModes:
  - ReadWriteOnce
  local:
    path: /node-v
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - {key: kubernetes.io/hostname, operator: In, values: [k8s-node1]}

-------------------------------------------
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-hostpath1
spec:
  capacity:
    storage: 1G
  accessModes:
  - ReadWriteOnce
  hostPath:
    path: /mnt/hostpath
ㅇㅇtype: DirectoryOrCreate



강의를 보니 둘다 PV를 만드는 yaml 인데 어떨때 hostpath를 넣는 거고 어떨때 local을 넣는 건가요??

그리고 type에서 directoryOrCreate는 hostpath나 local중 아무때나 넣어도 되나요?

답변 1

답변을 작성해보세요.

1

안녕하세요.

local은 affinity 룰이 같이 수반되어야 합니다. 내가 어떤 node에 pod를 생성할껀지의 설정까지 줄 경우 local을 쓸수 있고, 단순히 아무 node에나 path를 만들고 싶을 경우 hostpath를 쓰면되요.

결론적으로 node에 path를 만든다는 점은 같습니다.

그리고 type은 hostpath를 쓸 경우에만 사용할 수 있는 옵션이예요.