LABS – CERTIFIED KUBERNETES ADMINISTRATOR WITH PRACTICE TESTS > SCHEDULING
Scheduling
01. A pod definition file nginx.yaml is given. Create a pod using the file.
Only create the POD for now. We will inspect its status next.
- Pod nginx Created
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- image: nginx
name: nginx
kubectl apply -f ./nginx.yaml
# 혹은
kubectl create -f ./nginx.yaml
02. What is the status of the created POD?
root@controlplane:~# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx 0/1 Pending 0 2m22s
답 : Pending
03. Why is the POD in a pending state?
Inspect the environment for various kubernetes control plane components.
root@controlplane:~# kubectl get pods --namespace kube-system
NAME READY STATUS RESTARTS AGE
coredns-74ff55c5b-2ldlf 1/1 Running 0 17m
coredns-74ff55c5b-kvjjr 1/1 Running 0 17m
etcd-controlplane 1/1 Running 0 18m
kube-apiserver-controlplane 1/1 Running 0 18m
kube-controller-manager-controlplane 1/1 Running 0 18m
kube-flannel-ds-cwc6h 1/1 Running 0 17m
kube-flannel-ds-zcvns 1/1 Running 0 17m
kube-proxy-mn9rn 1/1 Running 0 17m
kube-proxy-rf9sb 1/1 Running 0 17m
Run the command:
kubectl get pods --namespace kube-system
to see the status of scheduler pod.
We have removed the scheduler from this Kubernetes cluster.
As a result, as it stands,
the pod will remain in a pending state forever.
# 1번 정답
(1) No Scheduler Present
# (2) Taints & Tolerations
# (3) No nodes available
# (4) Incorrect Label
04. Manually schedule the pod on node01.
Delete and recreate the POD if necessary.
- Status: Running
- Pod: nginx
Set nodeName property on the pod.
## 선택한 노드에 스케줄되도록 파드 생성하기
# pending 상태인 pod 삭제
kubectl delete pod nginx
# 파드가 선택한 노드에 실행중인지 확인
kubrctl get pods --output=wide
# nodeName 을 통해 특정노드로 파드를 배포할수 있다.
# pod-nginx-specific-node.yaml
--
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
nodeName: foo-node # 특정 노드에 파드 스케줄
containers:
- name: nginx
image: nginx
imagePullPolicy: IfNotPresent
05. Now schedule the same pod on the controlplane node.
Delete and recreate the POD if necessary.
- Status: Running
- Pod: nginx
- Node: controlplane?
:) 4번과 같은 방식으로 yaml 파일을 수정한다.
root@controlplane:~# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx 0/1 ContainerCreating 0 10s <none> controlplane <none> <none>
# 참고
https://kubernetes.io/ko/docs/concepts/scheduling-eviction/kube-scheduler/
'CKA (Certified Kubernetes Administrator) > Kode Kloud' 카테고리의 다른 글
02 Scheduling - Taints and Tolerations (0) | 2022.01.19 |
---|---|
02.Scheduling - Labels and Selectors (0) | 2022.01.19 |
01.CoreConcepts - Imperative Commands (0) | 2022.01.19 |
01.CoreConcepts - Service (0) | 2022.01.19 |
CKA - kode kloud 문제 풀이 [0] (0) | 2022.01.19 |