쿠버네티스 노드 구성 및 관리
파드 레이블(label)

- 노드의 레이블과 동일한 목적으로 사용
k label pod podName key=value
: 파드 레이블 부여k label pod podName key-
: 파드 레이블 부여k get pod -l key=value
: 특정 레이블을 가진 파드 조회
정적(Static) 파드
정적(Static) 파드로 구성하는 마스터 노드

kubelet
이 api
, etcd
, c-m
, sched
를 자동으로 배포

- 노드의
/etc/kubernetes/manifests/
에 설정 파일을 위치시킬경우 자동으로 배포 scp file node:/etc/kubernetes/manifests/
명령어로 복사도 가능- 이러한 파드는 쿠버네티스 스케줄러가 관리하지 않으므로 권장되지 않음
컨테이너 상태에 따른 동작(restartPolicy)

- 컨테이너의 종료/실패 여부에 따라 적절한 재시작 여부 설정 가능
- 애플리케이션/오브젝트 설정에 맞는 정책 설정 필요
애플리케이션 상태 탐사(startupProbe, livenessProbe, readinessProbe)
watch "kubectl describe po liveness-exec | tail"
과 같은 명령어로 탐사
탐사 방법 및 체크 방식 정리

livenessProbe-exec-periodSeconds10(->30).yaml

cat /tmp/healthy-on
이 실행되면 성공initialDelaySeconds
후 실행 / periodSeconds
주기로 체크
livenessProbe-httpGet.yaml

/healthz
로 요청을 보내서 health-check
라는 값을 받아오면 성공
livenessProbe-tcpSocket.yaml

readinessProbe-exec-periodSeconds5-w-lb.yaml

cat /tmp/health-on
이 실행되면 성공- 실행되지 않을 경우 컨테이너가 종료되는 대신 엔드포인트를 제거
startupProbe-w-others.yaml

startupProbe
-> livenessProbe
-> readinessProbe
순서로 동작
초기화(Init) 컨테이너

initContainers
를 사용하여 초기화 작업을 하는 애플리케이션을 별도의 컨테이너로 분리할 수 있음
멀티 컨테이너 패턴
- 메인 컨테이너는 비즈니스 로직에 집중하고 다른 역할을 하는 서비스는 컨테이너로 분리
- 실무에서는 3가지 패턴을 구분하여 사용하지는 않으나 이론적인 배경은 숙지할 것
사이드카(Sidecar)

- 메인 컨테이너를 확장하고 향상시키며 개선
- 사용 예시

앰버서더(Ambassador)

- 네트워크 연결을 전담하는 프록시 컨테이너를 둠
어댑터(Adapter)


파드 어피니티(affinity) 그리고 안티 어피니티

- 기준 파드의 레이블을 보고 파드를 배포
- 파드를 그룹 단위로 움직일 수 있음

affinity.podAffinity
로 파드 어피니티 지정

operator
를 NotIn
으로 설정하여 안티 어피니티 설정 가능
토폴로지 분배 제약 조건(topologySpreadConstraints)

- 전체 파드의 수를 보고 각 레이블 단위로 나눌 경우 사용
- 위와 같이 3번 노드에 부하가 심할 경우 토폴로지 분배 제약 조건을 이용하여 4개의 파드를 각각의 Zone에 2개씩 배포할 수 있음
Cloud AZ(Availability Zones / 가용 영역)

- 클라우드는 AZ 별로 같은 부하를 분배해야 할 필요성이 있음
- 토폴로지 분배 제약 조건을 이용하여 파드를 균등하게 분배

maxSkew
: 허용하는 파드 개수 차이whenUnsatisfiable
: 조건을 만족하지 않을 경우 취할 행동