Static PODs 란?
https://kubernetes.io/docs/tasks/configure-pod-container/static-pod/
static pod의 동작 원리
- API를 통하지 않고 파드가 생성된다.
- 각 노드의 kubelet에게 static pod 생성 요청
- /var/lib/kubelet/config.yaml -> kubelet 구성 정보, static 파드를 동작시킬 위치 정보가 등록되어 있음
- 기본값은 /etc/kubernetes/manifest로 되어있다.
- /etc/kubernetes/manifest 에 pod.yaml를 등록해주면 kubelet이 해당 yaml 파일을 기준으로 파드를 생성한다.
- master 의 API, Scheduler, ETCD, Controller 도 전부 static pod 형태로 동작한다.
1. How many static pods exist in this cluster in all namespaces?
$ controlplane ~ ➜ k get pod -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-flannel kube-flannel-ds-nrzlc 1/1 Running 0 11m
kube-flannel kube-flannel-ds-shwvw 1/1 Running 0 11m
kube-system coredns-768b85b76f-898jj 1/1 Running 0 11m
kube-system coredns-768b85b76f-gpwfz 1/1 Running 0 11m
kube-system etcd-controlplane 1/1 Running 0 11m
kube-system kube-apiserver-controlplane 1/1 Running 0 11m
kube-system kube-controller-manager-controlplane 1/1 Running 0 11m
kube-system kube-proxy-qr6qk 1/1 Running 0 11m
kube-system kube-proxy-wf8r8 1/1 Running 0 11m
kube-system kube-scheduler-controlplane 1/1 Running 0 11m
answer : 4
kube-system 에 controlplane 으로 실행중인 POD 들이 static POD 형태로 실행중이다.
2. Which of the below components is NOT deployed as a static pod?
answer : coredns
-> controlplane suffix 가 없다.
3. Which of the below components is NOT deployed as a static POD?
answer : kube-proxy
2번과 동일한 이유.
4. On which nodes are the static pods created currently?
answer : controlplane
5. What is the path of the directory holding the static pod definition files?
$ controlplane ~ ➜ ls /etc/kubernetes/manifests/
etcd.yaml kube-apiserver.yaml kube-controller-manager.yaml kube-scheduler.yaml
answer : /etc/kubernetes/manifests/
6. How many pod definition files are present in the manifests directory?
answer : 4
7. What is the docker image used to deploy the kube-api server as a static pod?
$ controlplane ~ ➜ k describe pod kube-apiserver-controlplane -n kube-system
...
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Pulled 22m kubelet Container image "registry.k8s.io/kube-apiserver:v1.30.0" already present on machine
Normal Created 22m kubelet Created container kube-apiserver
Normal Started 22m kubelet Started container kube-apiserver
answer : registry.k8s.io/kube-apiserver:v1.30.0
8. Create a static pod named static-busybox that uses the busybox image and the command sleep 1000
$ controlplane ~ ✖ kubectl run --restart=Never --image=busybox static-busybox --dry-run=client -o yaml --command -- sleep 1000 > static-busybox.yaml
$ controlplane ~ ➜ mv static-busybox.yaml /etc/kubernetes/manifests/
$ controlplane ~ ➜ k get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
default static-busybox-controlplane 1/1 Running 0 5s
kube-flannel kube-flannel-ds-nrzlc 1/1 Running 0 25m
kube-flannel kube-flannel-ds-shwvw 1/1 Running 0 25m
kube-system coredns-768b85b76f-898jj 1/1 Running 0 25m
kube-system coredns-768b85b76f-gpwfz 1/1 Running 0 25m
kube-system etcd-controlplane 1/1 Running 0 26m
kube-system kube-apiserver-controlplane 1/1 Running 0 26m
kube-system kube-controller-manager-controlplane 1/1 Running 0 26m
kube-system kube-proxy-qr6qk 1/1 Running 0 25m
kube-system kube-proxy-wf8r8 1/1 Running 0 25m
kube-system kube-scheduler-controlplane 1/1 Running 0 26m
9. Edit the image on the static pod to use busybox:1.28.4
$ controlplane ~ ➜ rm /etc/kubernetes/manifests/static-busybox.yaml
$ controlplane ~ ✖ kubectl run --restart=Never --image=busybox:1.28.4 static-busybox --dry-run=client -o yaml --command -- sleep 1000 > /etc/kubernetes/manifests/static-busybox.yaml
$ controlplane ~ ➜ k get pods
NAME READY STATUS RESTARTS AGE
static-busybox-controlplane 1/1 Running 0 2s
10. We just created a new static pod named static-greenbox. Find it and delete it.
This question is a bit tricky. But if you use the knowledge you gained in the previous questions in this lab, you should be able to find the answer to it.
$ controlplane ~ ➜ k get pods
NAME READY STATUS RESTARTS AGE
static-busybox-controlplane 1/1 Running 0 6m44s
static-greenbox-node01 1/1 Running 0 5m10s
10-1. static-greenbox 가 suffix가 node01 로 끝나므로 node01 노드에서 생성한 static-pod 라는것을 알수 있었다.
ssh를 이용하여 node01 로 접속해본다.
$ controlplane ~ ➜ ssh node01
Last login: Sun Jun 23 13:15:35 2024 from 192.20.241.10
10-2. 해당 노드로 접속한후 static pod 위치를 확인해본다.
static pod 정보는 kubelet 의 config 정보에 존재한다.
$ node01 ~ ➜ ps -ef | grep kubelet
root 12920 1 0 13:13 ? 00:00:08 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --container-runtime-endpoint=unix:///var/run/containerd/containerd.sock --pod-infra-container-image=registry.k8s.io/pause:3.9
$ node01 ~ ➜ cat /var/lib/kubelet/config.yaml | grep static
staticPodPath: /etc/just-to-mess-with-you
10-3. 해당 경로에 있는 greenbox.yaml 을 삭제한후 static-pod 가 종료되길 기다린다.
$ node01 /etc ➜ rm ./just-to-mess-with-you/greenbox.yaml
댓글