Table of Content
Kubernetes – 특정 Node에 Pod 배포하기
특정 Node에 Pod 배포하는 방법을 설명합니다.
각종 Echo System(Monitoring, Logging, Tracing 등)을 특정 Node 에 배치할 수 있어 좋습니다.
label 관련 명령 목록
# label 조회
kubectl get nodes --show-labels
NAME STATUS ROLES AGE VERSION LABELS
notebook Ready control-plane 27d v1.25.4 beta.kubernetes.io/arch=amd64,beta.kub.....
# label 추가
kubectl label nodes notebook key=infra
# label 조회
kubectl get nodes --show-labels
NAME STATUS ROLES AGE VERSION LABELS
notebook Ready control-plane 27d v1.25.4 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,key=infra,......
# node 조회
kubectl describe nodes notebook
kubectl describe nodes notebook
Name: notebook
Roles: control-plane
Labels: beta.kubernetes.io/arch=amd64
beta.kubernetes.io/os=linux
key=infra
......
# label 삭제
kubectl label nodes notebook key-
특정 Node 에 Pod 배포
kubectl label nodes notebook key=infra
kubectl edit deployment.apps/argocd-server -n argocd
---------------------------
spec:
template:
spec:
nodeSelector:
key: infra
# affinity:
# podAntiAffinity:
# preferredDuringSchedulingIgnoredDuringExecution:
# - podAffinityTerm:
# labelSelector:
# matchLabels:
# app.kubernetes.io/name: argocd-server
# topologyKey: kubernetes.io/hostname
# weight: 100
# - podAffinityTerm:
# labelSelector:
# matchLabels:
# app.kubernetes.io/part-of: argocd
# topologyKey: kubernetes.io/hostname
# weight: 5
---------------------------
Pod 가 다시 생성된 것을 볼 수 있습니다.
kubectl get pods -n argocd -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
argocd-application-controller-0 1/1 Running 0 5d21h 10.32.0.21 notebook <none> <none>
argocd-applicationset-controller-74575b6959-p9dv6 1/1 Running 0 5d21h 10.32.0.10 notebook <none> <none>
argocd-dex-server-64897989f8-bmjq8 1/1 Running 0 5d21h 10.32.0.14 notebook <none> <none>
argocd-notifications-controller-566bc99494-pvg2z 1/1 Running 0 5d21h 10.32.0.16 notebook <none> <none>
argocd-redis-79c755c747-94blj 1/1 Running 0 5d21h 10.32.0.18 notebook <none> <none>
argocd-repo-server-bc9c646dc-jpsnv 1/1 Running 0 5d21h 10.32.0.17 notebook <none> <none>
argocd-server-5989df56f8-drz4t 1/1 Running 0 105s 10.32.0.13 notebook <none> <none>
affinity
종류
- Node affinity
- Pod affinity
Node affinity
label 과 유사하게 Node 기준으로 Pod 를 배포합니다.
차이점은, label 은 특정 노드에 무조건 즉시 배포하는 반면,
Node affinity 는 무조건 할당할지 가능하면 할당할지,
이미 운영중인 Pod 를 제거하고 즉시 이동시킬지,
운영중인 Pod 는 그대로 두고 새로 생기는 Pod 만 할당할지를 정할 수 있습니다.
Pod affinity
Pod affinity 는 기존에 배포되어 있는 Pod 를 기준으로,
Master/Replica DB 가 하나의 노드에 배포되지 않도록 하거나,
N 개의 Pod 가 여러 노드에 골고루 배포되도록 할 때 사용합니다.