Post

Linux 쿠버네티스(5)

Linux 쿠버네티스(5)

볼륨 선언 - 볼륨 마운트

(PV선언과 PVC선언)- 볼륨 선언 - 볼륨 마운트
ㄴ 추가됨(볼륨에 대해 정의하고 추상화함)
-> 볼륨 크기, 권한, 스토리지 클래스 등의 볼륨 특성과 볼륨 정의를 해주는 것이 pv(전문가가 함)
-> pv요청이라는 뜻의 pvc는 사용자하는 것임(개발자 등등) 액세스모드, 스토리지모드, 저장공간의 최소 범위 등등을 매칭해줌(binding)
-> 이후 pvc를 보고 pod가 마운트를 진행함. spec 부분에서 마운트를 진행함.

  1. PV(Persistent Volume), PVC(Persistent Volume Client)
    1. PV & PVC
      • PV: 영구적인 볼륨 정의 및 특성 => 전문가 작성
      • PVC: PV 요청 => POD 실행하는 사람이 작성

    [참고] “이전 Volume” vs “PV/PVC volume”

    • 이전 Volume:
      • 볼륨 정의(Volumes) > 볼륨 마운트(volume Mounts)
    • PC/PVC volume:
      • PV 정의 > PVC 정의 > 파드(볼륨 정의 > 볼륨 마운트)
    1. PV(Persistent Volume)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    
     apiVersion: v1
     kind: PersistentVolume
     metadata:
     name: pv1
     spec:
     #볼륨 특성 정의
     capacity:
         storage: 4Gi
     volumeMode: Filesystem   # 생략해도 된다.(default), Filesystem|Block
     accessModes:
     - ReadWriteMany          # ReadWriteOnce, ReadWriteMany, ReadOnlyMany, ...
     storageClassName: manual
     persistentVolumeReclaimPolicy: Delete
     # 볼륨 정의
     nfs:
         server: 192.168.10.50
         path: /nas/k8s
    
    
    1. PVC(Persistent Volume Client)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
     kind: PersistentVolumeClaim
     apiVersion: v1
     metadata:
     name: pvc-web
     spec:
     # 볼륨의 특성으로 선택
     resources:
         requests:
         storage: 2Gi
     accessModes:
     - ReadWriteMany
     volumeMode: Filesystem 
     storageClassName: manual
    
  2. Storage Class
    -> 개별적으로 스터디
    개인적으로 스토리지 클래스에 대해 정리할 수 잇어야함.

오토 스케일링

용어

  • scale in/out : e.g. PC 개수 늘리기 / 줄이기
    -> scale in/out == Horizontal Autoscaling
    -> scale up/down == Vertical Autoscaling
  • scale up/down : e.g. PC 사양 높이기 / 낮추기

  • 오토 스케일링 종류
    • 클러스터 레벨 오토스케일링(VM 단위/실물로는 힘듦, 클라우드회사에서 제공)
      • Horizontal Cluster Autoscaling
      • Veritcal Cluster Autoscaling
    • 파드 레벨 오토스케일링(Pod 단위)
      • Horizontal Pod Autoscaling(HPA, 쿠버네티스에서 제공)
      • Veritcal Pod Autoscaling

HPA 오토 스케일링

  • (선수) Metrics-server addon이 필요
    • 각 노드/파드가 사용하는 CPU/MEM 사용량을 모니터링하고 데이터를 수집하는 역할
  • (동작 원리) HPA -넘김-> Deployment(RS{pod group})
    • HPA는 파드의 통계 자료나 상태들을 모니터링하고 이를 Deployment나 RS, RC처럼 파드를 관리하는 것들에게 넘긴다.
  • 동작 조건
    • 기본값 30초 간격으로 pod 사용량을 점검
    • 임계값을 초과하면 Pod 확장
    • 확장(scale-out)된 이후 3분 대기, 확장 이후 5분 대기하고 줄이기 작업

파드 스케줄링

Node Labels & Node Selector

  • 노드에 레이블을 지정하고 선택한다.
  • 용도: 지정된 노드에 파드를 배포

Affinity, Antiaffinity

  • Node Affinity
    [중요,참고] Node selector vs Affinity
    • Node selector : (단순 조건) Labels이 존재하는 노드에 파드를 배포하기
    • Node Affinity : (복합 조건) 지정된 조건(복합 조건)에 맞는 노드에 파드를 배포하기
  • Pod Affinity
    [참고] podAffinity vs podAntiAffinity
    • podAffinity: 파드를 가까이 배치(같은 노드에)
      • ex.) web pod, db pod
    • podAntiAffinity: 파드를 멀리 배치(다른 노드에)
      • ex.) db1 pod, db2 pod

        Taint, Tolerate

        tolerate : node taint가 설정되어있지만 파드를 올려야하는 경우에 쓴다. 그러면 해당 노드에 파드가 올라감 taint: 노드에 파드를 스케줄링 하지 않도록 설정하는 기능

        1. 노드 테인트(node taint)

[참고] “node label/node Selector” vs “taint”

  • node selector : 노드 레이블이 지정된 노드에 파드를 배포할 때 사용
  • node taint : 노드에 파드를 실행하지 않도록 할 때 사용
  • 노드 테인트 설정
    • #> kubectl taint nodes node1 role=web:NoSchedule
    • role=web:NoSchedule
    • role=web:PerferNosSchedule
  1. 파드 톨러레이션
    • node label » node selector
    • node taint » pod toleration
  • 사용 목적
    • 노드 테인트(NoSchedule)가 설정된 노드에 파드를 배포하고 싶을 때 사용
    • node taint(node.kubernetes.io/not-ready, node.kubernetes.io/unreachable)가 설정된 노드에 파드를 파드를 종료하고 싶을 때 사용
    1
    2
    3
    4
    5
    6
    
      # 양식
      tolerations:
      - key: ""
        operator: ""
        value: ""
        effect: Noschedule
    

Cordon, uncordon, drain

  1. Cordon/UnCordon
    • cordon : 지정된 노드에 파드 배포 금지
    • uncordon : 지정된 노드에 파드 배포 금지 해제

    #> kubectl cordon node1 #> kubectl uncordon node1

  2. Drain
    • drain : 지정된 노드에 모든 파드 삭제하기

[정리] 파드 스케쥴링

  • static pod
    • (관리용) 특정 노드에만 실행하고 싶은 파드를 배포(Kubelet)
  • daemonset
    • (관리용) 각 노드에 하개의 파드씩 배포
  • node label > node selector(Node Scheduler)
    • (서비스용) 특정 그룹 그룹에 실행하고 싶은 파들르 배포(Scheduler)
  • Node Affinity, Pod affinity, pod antiaffinity
    • Node Affinity
      • (서비스용) 특정 노드 그룹에 실행하고 싶은 파들르 배포(Scheduler에 의해 실행)
    • Pod Affinity/AntiAffinity
      • (서비스용) 특정 노드 그룹에 실행하고 싶은 파드와 파드들의 관계를 고려해서 배포(Scheduler에 의해 실행)
  • node taint, pod tolerate
    • NODE taint
      • (서비스용) 특정 노드 그룹의 파드를 배포하지 않을때(Scheduler에 의해)
    • POD tolerate
      • (서비스용) 노드 테인트가 설정된 파드에 파드를 배포하고 싶을 때(Scheduler에 의해)
This post is licensed under CC BY 4.0 by the author.