kubelet이 지정하는 Directory는 어느 Directory에나 될 수 있으나 그 디렉토리안에 반드시 Static POD의 Definition Yaml 파일이 있어야 한다.
ps -aux | grep kubelet 을 통해 config 값의 위치를 확인할 수 있다.
root 4835 0.0 0.1 4003092 107740 ? Ssl 06:39 1:06 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --network-plugin=cni --pod-infra-container-image=k8s.gcr.io/pause:3.2
여기서 위치는 /var/lib/kubelet/config.yaml이다.
cat /var/libe/kubelet/config.yaml 을 해보면
apiVersion: kubelet.config.k8s.io/v1beta1
authentication:
anonymous:
enabled: false
webhook:
cacheTTL: 0s
enabled: true
x509:
clientCAFile: /etc/kubernetes/pki/ca.crt
authorization:
mode: Webhook
webhook:
cacheAuthorizedTTL: 0s
cacheUnauthorizedTTL: 0s
cgroupDriver: cgroupfs
clusterDNS:
- 10.96.0.10
clusterDomain: cluster.local
cpuManagerReconcilePeriod: 0s
evictionPressureTransitionPeriod: 0s
fileCheckFrequency: 0s
healthzBindAddress: 127.0.0.1
healthzPort: 10248
httpCheckFrequency: 0s
imageMinimumGCAge: 0s
kind: KubeletConfiguration
logging: {}
nodeStatusReportFrequency: 0s
nodeStatusUpdateFrequency: 0s
resolvConf: /run/systemd/resolve/resolv.conf
rotateCertificates: true
runtimeRequestTimeout: 0s
shutdownGracePeriod: 0s
shutdownGracePeriodCriticalPods: 0s
staticPodPath: /etc/kubernetes/manifests
streamingConnectionIdleTimeout: 0s
syncFrequency: 0s
volumeStatsAggPeriod: 0s
위의 yaml에서
staticPodPath: /etc/kubernetes/manifests
경로를 확인할 수 있다.
[Practice Test]
ㅁ How many static pods exist in this cluster in all namespaces?
kubectl get pod --all-namespaces | grep "\-master"
ㅁ Which of the below components is NOT deployed as a static pod?
- coredns
- kube-apiserver
- etcd
- kube-controller-manager
ㅁ Which of the below components is NOT deployed as a static POD?
- kube-scheduler
- kube-controller-manager
- kube-apiserver
- kube-proxy
ㅁ On what nodes are the static pods create?
- controlplane & node01
- node01
- controlplane
- All Nodes
ㅁ What is the path of the directory holding the static pod definition files?
Run the command ps -aux | grep kubelet a
and identify the config file - --config=/var/lib/kubelet/config.yaml.
grep -i static /var/lib/kubelet/config.yaml
Then checkin the config file for staticPodPath.
staticPodPath: /etc/kubernetes/manifests
ㅁ How many pod definition files are present in the manifest folder?
ls -l /etc/kubernetes/manifests/ | wc -l
ㅁ What is the docker image used to deploy the kube-api server as a static pod?
cat /etc/kubernetes/manifests/kube-apiserver.yaml | grep image
ㅁ Create a static pod named static-busybox that uses the busybox image and the command sleep 1000
kubectl run static-busybox --image=busybox --command sleep 1000 --restart=Never --dry-run=client -o yaml > /etc/kubernetes/manifests/static-busybox.yaml
Static Pod의 경우 staticPodPath에 Pod 생성 yaml을 저장하는 것 만으로 Pod가 즉시 생성됨
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: static-busybox
name: static-busybox
spec:
containers:
- command:
- sleep
- "1000"
image: busybox
name: static-busybox
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Never
status: {}
ㅁ Edit the image on the static pod to use busybox:1.28.4
vi /etc/kubernetes/manifest/static-busybox.yaml
image 수정후 자동으로 Pod 생성
ㅁ Create a new static pod named static-greenbox. Find ti and delete it
Identify which node the static pod is created on, ssh to the node and delete the pod definition file.
If you don't know theIP of the node, run the kubectl get nodes -o wide command and identify the IP.
kubectl get pods --all-namespaces
kubectl get nodes -o wide
Then SSH to the node using that IP.
ssh node01
For static pod manifest path look at the file /var/lib/kubelet/config.yaml on node01
ps -ef | grep kubelete | grep "\--config"
--config=/var/lib/kubelet/config.yaml 확인
cat /var/lib/kubelet/config.yaml
or
grep -i static /var/lib/kubelete/config.yaml
apiVersion: kubelet.config.k8s.io/v1beta1
authentication:
anonymous:
enabled: false
webhook:
cacheTTL: 0s
enabled: true
x509:
clientCAFile: /etc/kubernetes/pki/ca.crt
authorization:
mode: Webhook
webhook:
cacheAuthorizedTTL: 0s
cacheUnauthorizedTTL: 0s
cgroupDriver: systemd
clusterDNS:
- 10.96.0.10
clusterDomain: cluster.local
cpuManagerReconcilePeriod: 0s
evictionPressureTransitionPeriod: 0s
fileCheckFrequency: 0s
healthzBindAddress: 127.0.0.1
healthzPort: 10248
httpCheckFrequency: 0s
imageMinimumGCAge: 0s
kind: KubeletConfiguration
logging: {}
nodeStatusReportFrequency: 0s
nodeStatusUpdateFrequency: 0s
resolvConf: /run/systemd/resolve/resolv.conf
rotateCertificates: true
runtimeRequestTimeout: 0s
staticPodPath: /etc/just-to-mess-with-you
streamingConnectionIdleTimeout: 0s
syncFrequency: 0s
volumeStatsAggPeriod: 0s
staticPodPath: /etc/just-to/mess-with-you를 찾아서 경로 이동
cd /etc/just-to/mess-with-you
에서 file delete 하면 static-pod는 알아서 삭제됨.
'CKA &. CKAD > Scheduling' 카테고리의 다른 글
Configuring Kubernetes Scheduler (0) | 2021.03.26 |
---|---|
Multiple Schedulers and Practice Test (0) | 2021.03.26 |
Practice Test - Daemon Sets (0) | 2021.03.26 |
Practice Test - Resource Limits (0) | 2021.03.26 |
PODs 와 Deployments를 편집하기위한 Quick note (0) | 2021.03.26 |