๋ ธ๋ ์ดํผ๋ํฐ/๋ ธ๋ ์ํฐ์ดํผ๋ํฐ/์ธํฐํ๋ ์ดํผ๋ํฐ/์ธํฐํ๋ ์ํฐ์ดํผ๋ํฐ๋ฅผ ์กฐํฉํ์ฌ ์ฌ์ฉ ๊ฐ๋ฅ
apiVersion: v1
kind: Pod
metadata:
name: sample-pod-complex-scheduling
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
~~~
preferredDuringSchedulingIgnoredDuringExecution:
~~~
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
~~~
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
~~~
- ํด๋ฌ์คํฐ๋ ์ฌ๋ฌ ํธ์คํธ/๋ฆฌ์ /์กด ๋ฑ์ ํ ํด๋ก์ง์ ๊ฑธ์ณ ๊ตฌ์ถ
- ํ ํด๋ก์ง๋ฅผ ์์ํ๊ณ ๊ท ๋ฑํ๊ฒ ๋ถ์ฐ ๋ฐฐ์นํ๋ ์ค์ผ์ค๋ง์ ๊ตฌํํ๊ธฐ ์ํด TopologySpreadConstraints ๋์
topologySpreadConstraints:
- topologyKey: topology.kubernetes.io/zone
labelSelector:
matchLabels:
app: sample-app
maxSkew: 1
wehnUnsatisfiable: DoNotSchedule
๊ฐ์ ์กด์ ํ ๊ฐ ํ๋/๊ฐ์ ํธ์คํธ์ ๋ ๊ฐ ํ๋์ ํธ์ฐจ๋ฅผ ํ์ฉํ๋ ์ค์ผ์ค๋ง ์์
topologySpreadConstraints:
- topologyKey: kubernetes.io/hostname
labelSelector:
matchLabels:
app: sample-app
maxSkew: 2
wehnUnsatisfiable: DoNotSchedule
- topologyKey: topology.kubernetes.io/zone
labelSelector:
matchLabels:
app: sample-app
maxSkew: 1
wehnUnsatisfiable: DoNotSchedule
์กฐ๊ฑด์ ๋ํด ๋ง์กฑํ์ง ์์ ๊ฒฝ์ฐ์ ๋์ ์ค์
- DoNotSchedule(๊ธฐ๋ณธ๊ฐ)
- ์กฐ๊ฑด์ ๋ง์กฑํ์ง ์์ผ๋ฉด ์ค์ผ์ค๋ง x
- ScheduleAnyway
- ์กฐ๊ฑด์ ๋ง์กฑํ์ง ์์๋ ์ฐ์ ์์๋ฅผ ๋ถ์ฌํ์ฌ ์ค์ผ์ค๋ง
๋ ธ๋์ ๋ํ taint๋ฅผ ์ค์ ํด ๋๊ณ ๊ทธ๊ฒ์ toleration ํ ์ ์๋ ํ๋๋ง ์ค์ผ์ค๋ง์ ํ๊ฐ
- ํ๋๊ฐ ์ ์ํ๊ณ ๋ ธ๋๊ฐ ํ๊ฐํ๋ ํํ
- ๋์ ๋
ธ๋๋ฅผ ํน์ ์ฉ๋๋ฅผ ์ํ ์ ์ฉ ๋
ธ๋๋ก ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์ฌ์ฉ ๊ฐ๋ฅ
- ex) ํ๋ก๋์ ์ฉ ๋ ธ๋์ ๋ค๋ฅธ ์ํฌ๋ก๋๋ฅผ ๋ฐฐ์นํ๊ณ ์ถ์ง ์์ ๊ฒฝ์ฐ
- ์กฐ๊ฑด์ ๋ง์ง ์๋ ํ๋๋ฅผ ๋ ธ๋์์์ ์ถ์ถ ๊ฐ๋ฅ
Key=Value:Effect ํ์์ผ๋ก ๊ตฌ์ฑ
- Key์ Value๋ ์์์ ๊ฐ์ผ๋ก ์ง์ , ์ผ์น ์ฌ๋ถ๋ฅผ ์กฐ๊ฑด์ผ๋ก ์ฌ์ฉ
- Effect:
- PreferNoSchedule: ๊ฐ๋ฅํ ํ ์ค์ผ์ค๋งํ์ง ์์
- NoSchedule: ์ค์ผ์ค๋งํ์ง ์์(์ด๋ฏธ ์ค์ผ์ค๋ง๋ ํ๋๋ ์ ์ง)
- NoExecute: ์คํ์ ํ๊ฐํ์ง ์์(์ด๋ฏธ ์ค์ผ์ค๋ง๋ ํ๋๋ ์ ์ง)
- kubectl taint ๋ช
๋ น์ด๋ฅผ ์ฌ์ฉ
- kubectl taint nodes {node-name} {key}={value}:{effect}
Key/Value/Effect๋ฅผ ์ง์ ํ๊ณ ํ ์ธํธ์์ ๋ถ์ฌ๋ Key/Value/Effect๊ฐ ๊ฐ์ ๊ฒฝ์ฐ์ ํ์ฉ
- Key/Value/Effect ์ค ํ๋๋ฅผ ๋ฏธ์ง์ ํ ๊ฒฝ์ฐ ์์ผ๋์นด๋
- spec.tolerations๋ก ์ง์
- Key ์กฐ๊ฑด์ ์คํผ๋ ์ดํฐ ์ข
๋ฅ:
- Equal: Key์ Value๊ฐ ๊ฐ๋ค
- Exists: Key๊ฐ ์กด์ฌํ๋ค
- PreferNoSchedule์ ๊ฒฝ์ฐ๋ ์กฐ๊ฑด์ด ์ผ์นํ์ง ์์๋ ์ค์ผ์ค๋ง๋์ง๋ง ์ฐ์ ์์๊ฐ ๋ด๋ ค๊ฐ
apiVersion: v1
kind: Pod
metadata:
name: sample-tolerations
spec:
containers:
- name: nginx-container
image: nginx:1.16
tolerations:
- key: "env"
operator: "Equal"
value: "prd"
effect: "NoSchedule"
tolerations:
- operator: "Exists"
Exists ์คํผ๋ ์ดํฐ๋ง ์ง์ ํ๋ฉด ๋ชจ๋ ์กฐ๊ฑด์ ์ผ์น์ํฌ ์ ์์
apiVersion: v1
kind: Pod
metadata:
name: sample-tolerations-second
spec:
containers:
- name: nginx-container
image: nginx:1.16
tolerations:
- key: "env"
operator: "Equal"
value: "prd"
effect: "NoExecute"
tolerationSeconds: 45
- ๋ ธ๋์๋ ์ฌ๋ฌ ๊ฐ์ ํ ์ธํธ ๋ถ์ฌ ๊ฐ๋ฅ
- ํ๋์ ํจ๋ฌ๋ ์ด์ ์ ๋ชจ๋ ํ ์ธํธ ์กฐ๊ฑด์ ๋ง์กฑํด์ผ ํ์ฉ
๋ ธ๋์ ์ฅ์ ๊ฐ ๋ฐ์ํ ๊ฒฝ์ฐ ์๋์ผ๋ก NoExecute์ ํ ์ธํธ๋ฅผ ๋ถ์ฌํ์ฌ ๋ ธ๋ ์ฅ์ ์ ์๋์ผ๋ก ํ๋๋ฅผ ์ถ์ถํ๋ ๊ธฐ๋ฅ
Effect | Key | ๊ฐ์ |
---|---|---|
NoExecute | node.kubernetes.io/not-ready | ๋ ธ๋ ์ํ๊ฐ Ready๊ฐ ์๋ ์ํ(NotReady) |
NoExecute | node.kubernetes.io/unreachable | ๋ ธ๋์์ ๋คํธ์ํฌ ์ ์์ด ๋์ง ์๋ ๊ฒฝ์ฐ(Unknown) |
tolerations:
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 300
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 300
Effect | Key | ๊ฐ์ |
---|---|---|
NoExecute | node.kubernetes.io/memory-pressure | ๋ ธ๋์ ๋ฉ๋ชจ๋ฆฌ ๋ถ์กฑ |
NoExecute | node.kubernetes.io/disk-pressure | ๋ ธ๋์ ๋์คํฌ ๋ถ์กฑ |
NoExecute | node.kubernetes.io/pid-pressure | ๋ ธ๋์ PID ๊ณ ๊ฐ |
NoExecute | node.kubernetes.io/network-unavailable | ๋ ธ๋์ ๋คํธ์ํฌ๊ฐ ์ฐ๊ฒฐ๋์ง ์์ |
NoExecute | node.kubernetes.io/unschedulable | kubectl cordon์ ์ํด ์ค์ผ์ค๋ง์์ ์ ์ธ๋จ |
Effect | Key | ๊ฐ์ |
---|---|---|
NoExecute | node.cloudprovider.kubernetes.io/uninitialized | ํด๋ผ์ฐ๋ ํ๋ก๋ฐ์ด๋์ ์ํด ๋ ธ๋๋ฅผ ์ฒ์ ๊ธฐ๋ํ ๋ ์ด๊ธฐํ๋๋ ๊ฒ์ ๋๊ธฐ |
NoExecute | node.cloudprovider.kubernetes.io/shutdown | ํด๋ผ์ฐ๋ ํ๋ก๋ฐ์ด๋์ ์ํด ๋ ธ๋๋ฅผ ์ ์งํ ๋ ์ ์ฒ๋ฆฌ |
- ์ฌ๋ฌ ํ๋๊ฐ ์ค์ผ์ค๋ง ๋๊ธฐ ์ํ์ผ ๊ฒฝ์ฐ ์ฐ์ ์์๋๋ก ์ค์ผ์ค๋ง ์์ ์ ๋ ฌ
- ๋ฆฌ์์ค์ ํ๊ณ๊น์ง ์ค์ผ์ค๋ง๋ ์ํ์์ ์ฐ์ ์์๊ฐ ๋ ๋์ ํ๋๋ฅผ ์์ฑํ๋ ค๋ ๊ฒฝ์ฐ ๊ธฐ์กด ํ๋ ์ถ์ถ ๊ฐ๋ฅ
- ์ฐ์ ์์(value)์ ์ค๋ช (description)์ผ๋ก ๊ตฌ์ฑ
- ์ฐ์ ์์ ๊ฐ์ด ๋์์๋ก ๋จผ์ ๊ธฐ๋ ์ํ ์ ์ง
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: sample-priority-class
value: 100
globalDefault: false
description: "used for serviceA only"
apiVersion: v1
kind: Pod
metadata:
name: sample-high-priority
spec:
containers:
- name: nginx-container
image: nginx:1.16
priorityClassName: sample-priority-class
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: sample-priority-class-preemption-policy
value: 100
globalDefault: false
description: "used for serviceA only"
preemptionPolicy: Never
- preemptionPolicy๋ฅผ Never๋ก ์ค์
- ์ฐ์ ์์๋๋ก ์ค์ผ์ค๋ง
- ์ถ์ถ x
PriorityClass์ ์ํ ์ถ์ถ ์ฒ๋ฆฌ๋ PodDisruptionBudget์ ๊ณ ๋ คํ์ฌ ์ค์ผ์ค๋ง ํ์ง๋ง ์ฐ์ ์์์ ๋ฐ๋ผ ๊ฐ์ ๋ก ์ถ์ถํ๋ฏ๋ก ์๋ฐํ๊ฒ๋ ๋ณด์ฅ x
apiVersion: v1
kind: Pod
metadata:
name: sample-custom-scheduler
spec:
schedulerName: custom-scheduler
containers:
- name: nginx-container
image: nginx:1.16
apiVersion: v1
kind: Pod
metadata:
name: sample-nodespecific-scheduler
spec:
nodeName: gke-k8s-default-pool-be722c17-7ij3
containers:
- name: nginx-container
image: nginx:1.16