이세개발
article thumbnail

Kubernetes Storage_Hostpath

쿠버네티스에서 hostPath 볼륨은 노드의 파일 시스템에 있는 파일이나 디렉터리를 파드에 마운트하는 데 사용됩니다. 이는 개발 및 테스트 환경에서 유용하며, 특히 단일 노드 클러스터에서 사용됩니다.

다음은 각 YAML 파일에 대한 설명입니다.


myapp-rs-hp.yaml

이 YAML 파일은 ReplicaSet을 정의합니다. 이 ReplicaSet은 두 개의 파드를 생성하며, 각 파드는 hostPath 볼륨을 사용하여 노드의 특정 디렉터리를 마운트합니다.

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: myapp-rs-hp
spec:
  replicas: 2
  selector:
    matchLabels:
      app: myapp-rs-hp
  template:
    metadata:
      labels:
        app: myapp-rs-hp
    spec:
      #nodeName: kube-node1
      containers:
      - name: web-server
        image: nginx:alpine
        volumeMounts:
        - name: web-content
          mountPath: /usr/share/nginx/html
        ports:
        - containerPort: 80
      volumes:
      - name: web-content
        hostPath:
          type: Directory
          path: /srv/web_contents

myapp-svc-hp.yaml

이 YAML 파일은 Service를 정의합니다. 이 서비스는 LoadBalancer 타입이며, myapp-rs-hp 레이블을 가진 파드로 트래픽을 라우팅합니다.

apiVersion: v1
kind: Service
metadata:
  name: myapp-svc-hp
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 80
  selector:
    app: myapp-rs-hp

profile

이세개발

@print(name)

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!