KR_K8s_Scheduling - somaz94/DevOps-Engineer GitHub Wiki
Pod Priority๋ ๋ฆฌ์์ค ๋ถ์กฑ ์ ์ด๋ค Pod๋ฅผ ๋จผ์ ์ข ๋ฃํ ์ง ๊ฒฐ์ ํ๋ค.
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: high-priority
value: 1000000
globalDefault: false
description: "Critical system pods"- System-critical(1์ต): kube-system ์ปดํฌ๋ํธ
- Production-high(100๋ง): ํต์ฌ ์๋น์ค
- Production-normal(10๋ง): ์ผ๋ฐ ์๋น์ค
- Best-effort(0): ๋ฐฐ์น ์์
Preemption(์ ์ )์ ๋์ ์ฐ์ ์์ Pod๋ฅผ ์ํด ๋ฎ์ ์ฐ์ ์์ Pod๋ฅผ ์ถ์ถํ๋ค.
์ฃผ์์ฌํญ: PDB์ ํจ๊ป ์ฌ์ฉํ์ฌ ๊ณผ๋ํ Preemption ๋ฐฉ์ง, preemptionPolicy: Never๋ก ์ ์ ๋นํ์ฑํ ๊ฐ๋ฅ, ๋ฆฌ์์ค ํ ๋น๋๊ณผ ์กฐํฉํ์ฌ ๊ณต์ ์ฑ ๋ณด์ฅ.
๋ ๋ฉ์ปค๋์ฆ ๋ชจ๋ Pod ๋ถ์ฐ์ ์ ์ดํ์ง๋ง ์ ๊ทผ ๋ฐฉ์์ด ๋ค๋ฅด๋ค.
- ํน์ Label Pod์ ๊ฐ์ ๋ ธ๋/AZ์ ๋ฐฐ์น๋์ง ์๋๋ก ์ ํ, ์ด์ง๋ฒ์ (๋ฐฐ์น ๊ฐ๋ฅ/๋ถ๊ฐ๋ฅ), ์๊ฒฉํ ๋ถ๋ฆฌ.
- Pod๋ฅผ ํ ํด๋ก์ง ๋๋ฉ์ธ(๋ ธ๋/AZ/๋ฆฌ์ )์ ๊ท ๋ฑ ๋ถ์ฐ, maxSkew๋ก ๋ถ๊ท ํ ํ์ฉ ๋ฒ์ ์ค์ , ์ ์ฐํ ๋ถ์ฐ.
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: web์ ํ ๊ธฐ์ค: ์ ๋์ ๋ถ๋ฆฌ(DB Primary/Replica)๋ Anti-Affinity, ๊ท ๋ฑ ๋ถ์ฐ(Stateless ์ฑ)์ Topology Spread, ๋ฉํฐ AZ ๊ณ ๊ฐ์ฉ์ฑ์ Topology Spread with maxSkew=1.
Taint๋ ๋ ธ๋์ ์ค์ ํ์ฌ ํน์ Pod๋ง ์ค์ผ์ค๋๋๋ก ์ ํํ๋ค.
NoSchedule:
- Toleration ์๋ Pod๋ ์ค์ผ์ค ์ ๋จ, ๊ธฐ์กด Pod๋ ์ํฅ ์์, ์ ๊ท ์ํฌ๋ก๋ ์ฐจ๋จ.
PreferNoSchedule:
- ๊ฐ๋ฅํ๋ฉด ์ค์ผ์ค ์ ํ์ง๋ง ๋ฆฌ์์ค ๋ถ์กฑ ์ ํ์ฉ, ์ํํธ ์ ์ฝ, ์ฐ์ ์์ ๋ฎ์ ์ํฌ๋ก๋.
NoExecute:
- ๊ธฐ์กด Pod๋ ์ถ์ถ, Toleration ์์ผ๋ฉด ์ฆ์ ์ข ๋ฃ, tolerationSeconds๋ก ์ ์ ์๊ฐ ์ค์ , ๋ ธ๋ ์ ์ง๋ณด์ ์ ์ฌ์ฉ.
# GPU ๋
ธ๋์ Taint ์ค์
kubectl taint nodes gpu-node nvidia.com/gpu=true:NoSchedule
# ์ ์ง๋ณด์ ๋ชจ๋
kubectl taint nodes node-1 maintenance=true:NoExecuteSpot ์ธ์คํด์ค๋ NoSchedule, ์ฅ์ ๋ ธ๋๋ NoExecute, ํน์ ํ๋์จ์ด(GPU/ARM)๋ Taint + Toleration ์กฐํฉ.
Kubernetes๋ ๊ธฐ๋ณธ ์ค์ผ์ค๋ฌ ์ธ์ ์ปค์คํ ์ค์ผ์ค๋ฌ๋ฅผ ์ถ๊ฐํ ์ ์๋ค.
- ํ๋์ ์ค์ผ์ค๋ฌ๊ฐ ์ฌ๋ฌ ํ๋กํ์ผ ์ ๊ณต, ํ๋ฌ๊ทธ์ธ ์กฐํฉ์ผ๋ก ๋ค๋ฅธ ์ค์ผ์ค๋ง ๋ก์ง ๊ตฌํ.
apiVersion: kubescheduler.config.k8s.io/v1
kind: KubeSchedulerConfiguration
profiles:
- schedulerName: default-scheduler
- schedulerName: no-scoring-scheduler
plugins:
score:
disabled:
- name: '*'- ์์ ํ ๋ ๋ฆฝ์ ์ธ ์ค์ผ์ค๋ฌ ๋ฐฐํฌ, ML ์ํฌ๋ก๋์ฉ GPU ์ต์ ํ ์ค์ผ์ค๋ฌ, ๋ฐฐ์น ์์ ์ฉ ๋นํจํน ์ค์ผ์ค๋ฌ.
Pod์์ schedulerName ์ง์ ํ์ฌ ์ ํ.
์ค๋ฌด: ๊ธฐ๋ณธ ์ค์ผ์ค๋ฌ๋ก ๋๋ถ๋ถ ์ฒ๋ฆฌ, ํน์ ์๊ตฌ์ฌํญ(Volcano for Batch, Yunikorn for Multi-tenancy)๋ง ๋ณ๋ ์ค์ผ์ค๋ฌ ์ฌ์ฉ.
๋๊ท๋ชจ ํด๋ฌ์คํฐ๋ API Server, etcd, Scheduler ๋ณ๋ชฉ์ด ๋ฐ์ํ๋ค.
-
--max-requests-inflight์ฆ๊ฐ(400 โ 800),--max-mutating-requests-inflight์ฆ๊ฐ(200 โ 400), API Priority and Fairness ํ์ฉ, ์ฝ๊ธฐ ์ ์ฉ ์ฟผ๋ฆฌ๋ ์บ์ ์ฌ์ฉ.
- SSD ํ์,
--quota-backend-bytes=8GB, Compaction ์๋ํ, ๋ณ๋ ๋ฌผ๋ฆฌ ์๋ฒ ๋ฐฐ์น, 5๋ ธ๋ ํด๋ฌ์คํฐ๋ก ํ์ฅ.
-
--kube-api-qps,--kube-api-burst์ฆ๊ฐ, Informer cache ์ต์ ํ, IPVS ๋ชจ๋ ์ฌ์ฉ(iptables ๋์ ).
- Node lease ๋ฉ์ปค๋์ฆ์ผ๋ก heartbeat ์ต์ ํ, CoreDNS ์บ์ ์ฆ๊ฐ ๋ฐ replicas ์ฆ๊ฐ, Webhook ํ์์์ ๋จ์ถ, ResourceQuota๋ก ํญํ ๋ฐฐํฌ ๋ฐฉ์ง.
Prometheus๋ก apiserver_request_duration_seconds, etcd_disk_backend_commit_duration_seconds ๋ชจ๋ํฐ๋ง.
๐ก ์ฉ์ด ์ค๋ช :
- ๊ณ ๊ธ ์ค์ผ์ค๋ง ๊ด๋ จ ์ฉ์ด๋ค(PriorityClass, Preemption, Topology Spread Constraints, Taint, Toleration, Scheduler Profile ๋ฑ)์ ๋ํ
- ์์ธํ ์ค๋ช ์ ๋ฌธ์ ์๋จ์ ์ฃผ์ ์ฉ์ด ํตํฉ ์ ๋ฆฌ > ์ค์ผ์ค๋ง ๋ฐ ๋ฆฌ์์ค ๊ด๋ฆฌ ์น์ ์ ์ฐธ๊ณ ํ์ธ์.