K8s ํด๋Ÿฌ์Šคํ„ฐ์˜ ๋…ธ๋“œ ์ „์ฒด์— Pod์„ ๋„์šธ ๋•Œ ์‚ฌ์šฉํ•˜๋Š” โ€œ์ปจํŠธ๋กค๋Ÿฌโ€๋‹ค.

2 minute read

K8s ํด๋Ÿฌ์Šคํ„ฐ์˜ ๋…ธ๋“œ ์ „์ฒด์— Pod์„ ๋„์šธ ๋•Œ ์‚ฌ์šฉํ•˜๋Š” โ€œ์ปจํŠธ๋กค๋Ÿฌโ€๋‹ค.

์ปจํŠธ๋กค๋Ÿฌ๋Š” K8s์˜ ๊ธฐ๋ณธ ์˜ค๋ธŒ์ ํŠธ(Pod)์„ ์ƒ์„ฑํ•˜๊ณ , ์ด๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ์—ญํ• ์„ ํ•œ๋‹ค. ReplicaSet, Deployment, DaemonSet์ด ์ปจํŠธ๋กค๋Ÿฌ ๋ฆฌ์†Œ์Šค์— ์†ํ•œ๋‹ค.

DaemonSet์€ ๋ชจ๋“  ๋…ธ๋“œ์— Pod์„ ๋„์›Œ์ค€๋‹ค. ๊ทธ๋ž˜์„œ ๋กœ๊น…(Logging)์ด๋‚˜ K8s ๋„คํŠธ์›Œํฌ ๊ด€๋ จ Pod์ด DaemonSet์œผ๋กœ ๊ด€๋ฆฌ๋œ๋‹ค.

DaemonSet ์ƒ์„ฑ

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: my-daemonset
  namespace: kube-system
spec:
  selector:
    matchLabels:
      name: my-daemon
  updateStrategy:
    type: RollingUpdate
  template:
    ...

๋ฐ๋ชฌ์…‹ ์˜ˆ์‹œ

CNI Network Plugin

https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml

Network Policy ๋ฆฌ์†Œ์Šค ๋“ฑ์„ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜๋Š” Network Plugin์€ DaemonSet ๋ฆฌ์†Œ์Šค๋กœ ์šด์˜ํ•œ๋‹ค. weave net, calico, flannel ๋“ฑ์ด CNI Network Plugin์ด๋‹ค.

(DaemonSet์— ๋Œ€ํ•œ ๋‚ด์šฉ์€ ์•„๋‹ˆ์ง€๋งŒ) Service ๊ฒ€์ƒ‰ ์• ๋“œ์˜จ์ธ โ€œcoreDNSโ€๊ฐ€ ๋™์ž‘ํ•˜๋ ค๋ฉด ์ด๋Ÿฐ ๋„คํŠธ์›Œํฌ ํ”Œ๋Ÿฌ๊ทธ์ธ์ด ์„ค์น˜๋˜์–ด ์žˆ์–ด์•ผ ํ•œ๋‹ค.

๋ชจ๋‹ˆํ„ฐ๋ง ๋„๊ตฌ

https://www.datadoghq.com/blog/monitoring-kubernetes-with-datadog/

Datadog๊ณผ ๊ฐ™์€ ์ธํ”„๋ผ ๋ชจ๋‹ˆํ„ฐ๋ง ๋„๊ตฌ ์—ญ์‹œ DaemonSet ๋ฆฌ์†Œ์Šค๋กœ ์šด์˜ํ•œ๋‹ค.

kube-proxy

K8s Cluster

https://github.com/openshift/cluster-network-operator/blob/master/bindata/kube-proxy/kube-proxy.yaml

K8s ํด๋Ÿฌ์Šคํ„ฐ์—์„œ Service ์˜ค๋ธŒ์ ํŠธ๊ฐ€ ๋™์ž‘ํ•˜๋Š” ๊ฒƒ์„ ๊ฐ€๋Šฅ์ผ€ ํ•˜๋Š” ์กด์žฌ๋‹ค. kube-proxy๋Š” ์ƒˆ๋กœ์šด Service๊ฐ€ ์ƒ๊ธธ ๋•Œ๋งˆ๋‹ค ํ•ด๋‹น ์„œ๋น„์Šค์— ๋ฐ”์ธ๋”ฉ๋œ Pod์œผ๋กœ ํŠธ๋ž˜ํ”ฝ์ด ๊ฐˆ ์ˆ˜ ์žˆ๋„๋ก ๊ทœ์น™์„ ๋งŒ๋“ค์–ด ์ €์žฅํ•œ๋‹ค.

์ฆ‰, Service ๋ฆฌ์†Œ์Šค๊ฐ€ ์ •์ƒ ๋™์ž‘ํ•˜๋ ค๋ฉด, kube-proxy DaemonSet์ด ์ž˜ ๊ตฌ์ถ•๋˜์–ด ์žˆ์–ด์•ผ ํ•œ๋‹ค. Service ๋ฆฌ์†Œ์Šค๋Š” ์‹ค์ œ๋กœ ์กด์žฌํ•ด ๋…ธ๋“œ์˜ ์ž์›์„ ์ ์œ ํ•˜๋Š” ์กด์žฌ๊ฐ€ ์•„๋‹ˆ๋ผ kube-proxy์˜ ๊ทœ์น™์ผ ๋ฟ์ด๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค!

kubelet์€ DaemonSet์ด ์•„๋‹ˆ๋‹ค

[stackoverflow] Is the kubernetes kubelet a DaemonSet?

K8s ํด๋Ÿฌ์Šคํ„ฐ์— ๋Œ€ํ•œ ์•„ํ‚คํ…์ฒ˜ ๊ทธ๋ฆผ์„ ๋ณด๋ฉด, ๊ฐ ๋…ธ๋“œ์— kubelet์™€ kube-proxy๊ฐ€ ์กด์žฌํ•˜๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. ์•ž์—์„œ kube-proxy๋Š” DaemonSet์œผ๋กœ ๋™์ž‘ํ•œ๋‹ค๋Š” ๊ฒƒ์„ ๋ดค๋Š”๋ฐ, kubelet๋„ ๊ทธ๋Ÿด๊นŒ? ๋‹ต์€ โ€œkubelet์€ Pod์ด ์•„๋‹ˆ๋‹คโ€!

kubelet์€ Pod์ด ์•„๋‹ˆ๋ผ ๋ฐ๋ชฌ ํ”„๋กœ์„ธ์Šค(daemon process)๋‹ค. K8s ํด๋Ÿฌ์Šคํ„ฐ ๋™์ž‘ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” ํ”„๋กœ์„ธ์Šค๋กœ (1) ๋…ธ๋“œ๋ฅผ ํด๋Ÿฌ์Šคํ„ฐ์— ๋“ฑ๋กํ•˜๊ณ  (2) controlplane์œผ๋กœ ๋ถ€ํ„ฐ ์š”์ฒญ ๋ฐ›์€ ๋ฆฌ์†Œ์Šค ์ƒ์„ฑ ์š”์ฒญ์„ ์ˆ˜ํ–‰ํ•˜๋Š” ์—ญํ• ์„ ํ•œ๋‹ค.