DevOps/Kubernetes
Kubernetes::스케쥴링 (Scheduling) - 데몬셋
yscho03
2023. 12. 19. 22:55
728x90
반응형
데몬셋 (Daemon Sets)
개요
클러스터 전체 노드에 특정 파드를 실행할 때 사용하는 컨트롤러이다.
간략히 말해 각 노드에 항상 떠있는 데몬을 이야기한다.
DaemonSet는 모든(또는 일부) 노드가 Pod의 복사본을 실행하도록 한다.
노드가 클러스터에 추가되면 Pod가 여기에 추가된다. 클러스터에서 노드가 제거되면 해당 포드는 가비지 수집된다. DaemonSet를 삭제하면 생성된 Pod가 자동적으로 삭제된다.
용도
다음과 같은 용도로 사용할 수 있다.
- 모든 노드에서 클러스터 저장소 데몬 실행
- 모든 노드에서 로그 수집 데몬 실행
- 모든 노드에서 노드 모니터링 데몬 실행
시나리오
- Deamonset 생성
$ cat > daemonset.yaml
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
$ kubectl create -f daemonset.yaml
- Deamonset 조회
$ kubectl get ds -n kube-system
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
fluentd-elasticsearch 2 2 2 2 2 20s
kube-proxy 3 3 3 3 3 kubernetes.io/os=linux 347d
weave-net 3 3 3 3 3 347d
- POD 조회
$ kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
fluentd-elasticsearch-7r84t 1/1 Running 0 55s
fluentd-elasticsearch-wps54 1/1 Running 0 55s
728x90
반응형