[k8s] KodeKloud Practice test - Static pod
Q1. How many static pods exist in this cluster in all namespaces?
A1. 4
일반적으로 Static Pod는 /etc/kubernetes/mainfests 하위에 yaml 파일을 위치하게 된다.
일반적으로 pod를 만드는 yaml을 두면 되고, 일반적으로 pod는 name 뒤에 의문의 문자열이 생기는데 static pod는 name 뒤에 node name이 붙게된다.
static pod의 개수는 /etc/kubernetes/mainfests의 yaml 파일 개수를 확인해도 도고, pod의 name에 node가 붙어있는것을 확인하면 된다.
Q2. Which of the below components is NOT deployed as a static pod?
A2. coredns
Q3. Which of the below components is NOT deployed as a static POD?
A3. kube-proxy
Q4. On which nodes are the static pods created currently?
A4. controlplane
Q5. What is the path of the directory holding the static pod definition files?
A5. /etc/kubernetes/mainfests
Q6. How many pod definition files are present in the manifests folder?
A6. 4
Q7. What is the docker image used to deploy the kube-api server as a static pod?
A7. k8s.gcr.io/kube-proxy:v1.24.0
Q8. Create a static pod named static-busybox that uses the busybox image and the command sleep 1000
A8. k run static-busybox --image=busybox --dry-run=client -o yaml > 8.yaml 처럼하면 쉽게 할 수 있다.
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: static-busybox
name: static-busybox
spec:
containers:
- image: busybox
name: static-busyboux
command: ["sleep"]
args: ["1000"]
Q9. Edit the image on the static pod to use busybox:1.28.4
A9. Q8.에서 만들었던 8.yaml에서 image 정보만 수정하고 kubectl replace --force -f 8.yaml을 하면 된다.
Q10. 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.
A10.
이번 문제는 이전의 연습문제와는 다르게 조금 복잡하다.
먼저, greenbox의 pod name을 보면 static pod임을 알 수 있다.
그렇다면 삭제하기 위해서는 node01로 들어가서 /etc/kubernetes/mainfests에서 greenbox의 yaml을 삭제하면 된다.
근데 이상하게 manifests 폴더에 들어가니깐 아래와 같이 yaml 파일이 없다!! 여기에서 일차 멘붕이 와서 찾아보니
일반적으로 static pod의 위치는 /etc/kubernetes/mainfests 이지만, kubectl의 config 파일이 있는 /var/lib/kubelet/config.yaml 파일에서 staticPodPath를 수정할 수 있다는것을 알았다!!
실제로 /var/lib/kubelet/config.yaml 파일을 보면 staticpodpath가 임의 지정되어 있고, 해당 경로에 들어가면 greenbox yaml이 있다!!
staticpodpath에서 greenbox의 yaml을 삭제하면 아래와 같이 delete 후에 pod가 다시 생성되지 않늗다!! 굳!!
끝!!