[cka] DaemonSets
DaemonSet ?
https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/
DaemonSet
A DaemonSet defines Pods that provide node-local facilities. These might be fundamental to the operation of your cluster, such as a networking helper tool, or be part of an add-on.
kubernetes.io
각 노드마다 필수적으로 실행되는 Pod, 노드가 생성될때 생성되고 노드가 삭제되면 삭제되는 Pod 이다.
1. How many DaemonSets are created in the cluster in all namespaces?
Check all namespaces
controlplane ~ ➜ k get daemonsets.apps -A
NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
kube-flannel kube-flannel-ds 1 1 1 1 1 <none> 5m24s
kube-system kube-proxy 1 1 1 1 1 kubernetes.io/os=linux 5m25s
answer : 2
2. Which namespace is the kube-proxy Daemonset created in?
kubectl get all --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-flannel pod/kube-flannel-ds-pttqs 1/1 Running 0 24m
kube-system pod/coredns-768b85b76f-8btn4 1/1 Running 0 24m
kube-system pod/coredns-768b85b76f-dzkxh 1/1 Running 0 24m
kube-system pod/etcd-controlplane 1/1 Running 0 25m
kube-system pod/kube-apiserver-controlplane 1/1 Running 0 25m
kube-system pod/kube-controller-manager-controlplane 1/1 Running 0 25m
kube-system pod/kube-proxy-qvnp7 1/1 Running 0 24m
kube-system pod/kube-scheduler-controlplane 1/1 Running 0 25m
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 25m
kube-system service/kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 25m
NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
kube-flannel daemonset.apps/kube-flannel-ds 1 1 1 1 1 <none> 25m
kube-system daemonset.apps/kube-proxy 1 1 1 1 1 kubernetes.io/os=linux 25m
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
kube-system deployment.apps/coredns 2/2 2 2 25m
NAMESPACE NAME DESIRED CURRENT READY AGE
kube-system replicaset.apps/coredns-768b85b76f 2 2 2 24m
answer : kube-flannel-ds
4. On how many nodes are the pods scheduled by the DaemonSet kube-proxy?
controlplane ~ ➜ k get daemonsets.apps -A
NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
kube-flannel kube-flannel-ds 1 1 1 1 1 <none> 39m
kube-system kube-proxy 1 1 1 1 1 kubernetes.io/os=linux 39m
answer : 1
5. What is the image used by the POD deployed by the kube-flannel-ds DaemonSet?
controlplane ~ ➜ k get daemonsets.apps -A -o wide
NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE CONTAINERS IMAGES SELECTOR
kube-flannel kube-flannel-ds 1 1 1 1 1 <none> 16m kube-flannel docker.io/flannel/flannel:v0.23.0 app=flannel,k8s-app=flannel
kube-system kube-proxy 1 1 1 1 1 kubernetes.io/os=linux 16m kube-proxy registry.k8s.io/kube-proxy:v1.30.0 k8s-app=kube-proxy
answer : docker.io/flannel/flannel:v0.23.0
6. Deploy a DaemonSet for FluentD Logging. Use the given specifications.
controlplane ~ ➜ kubectl create deployment elasticsearch --image=registry.k8s.io/fluentd-elasticsearch:1.20 -n kube-system --dry-run=client -o yaml > fluentd.yaml
### fluentd.yaml
apiVersion: apps/v1
kind: DaemonSet # Deployment -> DaemonSet 변경
metadata:
creationTimestamp: null
labels:
app: elasticsearch
name: elasticsearch
namespace: kube-system
spec:
# replicas: 1 # 제거
selector:
matchLabels:
app: elasticsearch
# strategy: {} 제거
template:
metadata:
creationTimestamp: null
labels:
app: elasticsearch
spec:
containers:
- image: registry.k8s.io/fluentd-elasticsearch:1.20
name: fluentd-elasticsearch
resources: {}
status: {}
##
controlplane ~ ➜ k apply -f fluentd.yaml
daemonset.apps/elasticsearch created