https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/
๋ฐ๋ชฌ์ ์ ๋ชจ๋ (๋๋ ์ผ๋ถ) ๋ ธ๋๊ฐ ํ๋์ ์ฌ๋ณธ์ ์คํํ๋๋ก ํ๋ค. ๋ ธ๋๊ฐ ํด๋ฌ์คํฐ์ ์ถ๊ฐ๋๋ฉด ํ๋๋ ์ถ๊ฐ๋๋ค. ๋ ธ๋๊ฐ ํด๋ฌ์คํฐ์์ ์ ๊ฑฐ๋๋ฉด ํด๋น ํ๋๋ ๊ฐ๋น์ง(garbage)๋ก ์์ง๋๋ค. ๋ฐ๋ชฌ์ ์ ์ญ์ ํ๋ฉด ๋ฐ๋ชฌ์ ์ด ์์ฑํ ํ๋๋ค์ด ์ ๋ฆฌ๋๋ค.
- ๋ชจ๋ ๋ ธ๋์์ ํด๋ฌ์คํฐ ์คํ ๋ฆฌ์ง ๋ฐ๋ชฌ ์คํ
- ๋ชจ๋ ๋ ธ๋์์ ๋ก๊ทธ ์์ง ๋ฐ๋ชฌ ์คํ
- ๋ชจ๋ ๋ ธ๋์์ ๋ ธ๋ ๋ชจ๋ํฐ๋ง ๋ฐ๋ชฌ ์คํ
๋ ธ๋๋น ํฌ๋๋ฅผ ํ๋์ฉ๋ง ๋ฐฐ์นํจ -> ๋ ธ๋ ๊ด๋ฆฌํ์ผ๋ก ์ฌ์ฉ๋๊ธฐ๋ ํจ.
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluentd-elasticsearch
namespace: kube-system
labels:
k8s-app: fluentd-logging
spec:
selector:
matchLabels:
name: fluentd-elasticsearch
template:
metadata:
labels:
name: fluentd-elasticsearch
spec:
tolerations: # ๋ง์คํฐ ๋
ธ๋์์๋ ์คํ ๊ฐ๋ฅํ๊ฒ ํ๋ ์ต์
# these tolerations are to have the daemonset runnable on control plane nodes
# remove them if your control plane nodes should not run pods
- key: node-role.kubernetes.io/control-plane
operator: Exists
effect: NoSchedule
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
containers:
- name: fluentd-elasticsearch
image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 200Mi
volumeMounts:
- name: varlog
mountPath: /var/log
terminationGracePeriodSeconds: 30
volumes:
- name: varlog
hostPath:
path: /var/log
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: http-go
spec:
selector:
matchLabels:
app: http-go
template:
metadata:
labels:
app: http-go
spec:
tolerations:
- key: node-role.kubernetes.io/control-plane
operator: Exists
effect: NoSchedule
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
containers:
- name: http-go
image: gasbugs/http-go
https://kubernetes.io/ko/docs/concepts/scheduling-eviction/taint-and-toleration/
Taint ์ค์ ์ Toleration์ด ์ผ์นํด์ผ ๋ ธ๋์ ํ๋๊ฐ ์คํ๋ ์ ์๋ค.
Taint๊ฐ ์ค์ ๋์ด์์ง ์์ผ๋ฉด ๊ทธ๋ฅ ์คํ๋จ
Taint ์ค์ ๋์ด์๋๋ฐ Toleration์ด ์ผ์นํ์ง ์์ผ๋ฉด ํ๋๊ฐ ์คํ ๋ถ๊ฐ๋ฅํจ.
ํ ์ธํธ์ ํจ๋ฌ๋ ์ด์ ์ ํจ๊ป ์๋ํ์ฌ ํ๋๊ฐ ๋ถ์ ์ ํ ๋ ธ๋์ ์ค์ผ์ค๋์ง ์๊ฒ ํ๋ค. ํ๋ ์ด์์ ํ ์ธํธ๊ฐ ๋ ธ๋์ ์ ์ฉ๋๋๋ฐ, ์ด๊ฒ์ ๋ ธ๋๊ฐ ํ ์ธํธ๋ฅผ ์ฉ์ธํ์ง ์๋ ํ๋๋ฅผ ์์ฉํด์๋ ์ ๋๋ค๋ ๊ฒ์ ๋ํ๋ธ๋ค
kubectl taint nodes node1 key1=value1:NoSchedule
: ๋
ธ๋์ ํ
์ธํธ ์ถ๊ฐ
kubectl taint nodes node1 key1=value1:NoSchedule-
: ๋
ธ๋์ ํ
์ธํธ ์ ๊ฑฐ
PodSpec์ Toleration ์ ์ฉ
tolerations: - key: "key1" operator: "Equal" value: "value1" effect: "NoSchedule" # kubectl taint nodes node1 key1=value1:NoSchedule ํด๋น Taint์ ์ผ์น
apiVersion: v1 kind: Pod metadata: name: nginx labels: env: test spec: containers: - name: nginx image: nginx imagePullPolicy: IfNotPresent tolerations: - key: "example-key" operator: "Exists" effect: "NoSchedule"
- operator: ๊ธฐ๋ณธ๊ฐ Equal
- effect:
- NoSchedule : ์ค์ผ์ค๋ง X,
- PreferNoSchedule: ํฌ๋๋ฅผ ๋ค๋ฅธ๊ณณ์ ๋ฐฐ์นํ ๋ ธ๋๊ฐ ์์ผ๋ฉด ๋ณธ์ธ์ด ๊ณ์ ์คํ
- NoExecute: ์คํ X (์ด๋ฏธ์คํ์ค์ธ ํฌ๋๋ฅผ ๋ ธ๋์์ ๋นผ๋ฒ๋ฆผ)
kubectl get nodes -o json | jq '.items[].spec.taints'