LABS – CERTIFIED KUBERNETES ADMINISTRATOR WITH PRACTICE TESTS > SCHEDULING
Scheduling
01. How many nodes exist on the system?
Including the controlplane node.
답 : 2
root@controlplane:~# kubectl get nodes
NAME STATUS ROLES AGE VERSION
controlplane Ready control-plane,master 12m v1.20.0
node01 Ready <none> 11m v1.20.0
02. Do any taints exist on node01 node?
답 : none
# 방법 1
kubectl describe node node01 | grep -i taints
# 방법 2
root@controlplane:~# kubectl describe nodes node01
Name: node01
Roles: <none>
Labels: beta.kubernetes.io/arch=amd64
beta.kubernetes.io/os=linux
kubernetes.io/arch=amd64
kubernetes.io/hostname=node01
kubernetes.io/os=linux
Annotations: flannel.alpha.coreos.com/backend-data: {"VNI":1,"VtepMAC":"86:15:39:88:4c:94"}
flannel.alpha.coreos.com/backend-type: vxlan
flannel.alpha.coreos.com/kube-subnet-manager: true
flannel.alpha.coreos.com/public-ip: 10.6.231.12
kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock
node.alpha.kubernetes.io/ttl: 0
volumes.kubernetes.io/controller-managed-attach-detach: true
CreationTimestamp: Wed, 19 Jan 2022 04:27:25 +0000
Taints: <none>
Unschedulable: false
Lease:
HolderIdentity: node01
AcquireTime: <unset>
RenewTime: Wed, 19 Jan 2022 04:42:35 +0000
Conditions:
Type Status LastHeartbeatTime LastTransitionTime Reason Message
---- ------ ----------------- ------------------ ------ -------
NetworkUnavailable False Wed, 19 Jan 2022 04:27:30 +0000 Wed, 19 Jan 2022 04:27:30 +0000 FlannelIsUp Flannel is running on this node
MemoryPressure False Wed, 19 Jan 2022 04:42:40 +0000 Wed, 19 Jan 2022 04:27:25 +0000 KubeletHasSufficientMemory kubelet has sufficient memory available
DiskPressure False Wed, 19 Jan 2022 04:42:40 +0000 Wed, 19 Jan 2022 04:27:25 +0000 KubeletHasNoDiskPressure kubelet has no disk pressure
PIDPressure False Wed, 19 Jan 2022 04:42:40 +0000 Wed, 19 Jan 2022 04:27:25 +0000 KubeletHasSufficientPID kubelet has sufficient PID available
Ready True Wed, 19 Jan 2022 04:42:40 +0000 Wed, 19 Jan 2022 04:27:36 +0000 KubeletReady kubelet is posting ready status
Addresses:
InternalIP: 10.6.231.12
Hostname: node01
Capacity:
cpu: 36
ephemeral-storage: 507944172Ki
hugepages-1Gi: 0
hugepages-2Mi: 0
memory: 214588000Ki
pods: 110
Allocatable:
cpu: 36
ephemeral-storage: 468121348141
hugepages-1Gi: 0
hugepages-2Mi: 0
memory: 214485600Ki
pods: 110
System Info:
Machine ID: e8574b7bc3784a8dbca351f47f17972f
System UUID: df4f7349-5604-cb04-432c-0c8012a6e595
Boot ID: 06683fbc-cc7d-4b3c-873c-79494ee99344
Kernel Version: 5.4.0-1060-gcp
OS Image: Ubuntu 18.04.5 LTS
Operating System: linux
Architecture: amd64
Container Runtime Version: docker://19.3.0
Kubelet Version: v1.20.0
Kube-Proxy Version: v1.20.0
PodCIDR: 10.244.1.0/24
PodCIDRs: 10.244.1.0/24
Non-terminated Pods: (2 in total)
Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits AGE
--------- ---- ------------ ---------- --------------- ------------- ---
kube-system kube-flannel-ds-vtzhr 100m (0%) 100m (0%) 50Mi (0%) 300Mi (0%) 15m
kube-system kube-proxy-rjcqx 0 (0%) 0 (0%) 0 (0%) 0 (0%) 15m
Allocated resources:
(Total limits may be over 100 percent, i.e., overcommitted.)
Resource Requests Limits
-------- -------- ------
cpu 100m (0%) 100m (0%)
memory 50Mi (0%) 300Mi (0%)
ephemeral-storage 0 (0%) 0 (0%)
hugepages-1Gi 0 (0%) 0 (0%)
hugepages-2Mi 0 (0%) 0 (0%)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Starting 15m kubelet Starting kubelet.
Normal NodeHasSufficientMemory 15m (x2 over 15m) kubelet Node node01 status is now: NodeHasSufficientMemory
Normal NodeHasNoDiskPressure 15m (x2 over 15m) kubelet Node node01 status is now: NodeHasNoDiskPressure
Normal NodeHasSufficientPID 15m (x2 over 15m) kubelet Node node01 status is now: NodeHasSufficientPID
Normal NodeAllocatableEnforced 15m kubelet Updated Node Allocatable limit across pods
Normal Starting 15m kube-proxy Starting kube-proxy.
Normal NodeReady 15m kubelet Node node01 status is now: NodeReady
03. Create a taint on node01 with key of spray, value of mortein and effect of NoSchedule
- Key = spray
- Value = mortein
- Effect = NoSchedule
kubectl taint nodes node01 spray=mortein:NoSchedule
04. Create a new pod with the nginx image and pod name as mosquito.
- Image name: nginx
방법 1 )
root@controlplane:~# kubectl run mosquito --image=nginx
pod/mosquito created
방법 2 )
# sample.yaml
# kubectl create -f sample.yaml
---
apiVersion: v1
kind: Pod
metadata:
name: mosquito
spec:
containers:
- image: nginx
name: mosquito
05. What is the state of the POD?
답 : Pending
root@controlplane:~# kubectl get pod
NAME READY STATUS RESTARTS AGE
mosquito 0/1 Pending 0 7s
06. Why do you think the pod is in a pending state?
1) Application Error
2) Image is not available
(정답) 3) POD Mosquito cannot tolerate taint Mortein
root@controlplane:~# kubectl describe pod mosquito
Name: mosquito
Namespace: default
Priority: 0
Node: <none>
Labels: run=mosquito
Annotations: <none>
Status: Pending
IP:
IPs: <none>
Containers:
mosquito:
Image: nginx
Port: <none>
Host Port: <none>
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-p8pp9 (ro)
Conditions:
Type Status
PodScheduled False
Volumes:
default-token-p8pp9:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-p8pp9
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedScheduling 10s (x4 over 2m24s) default-scheduler 0/2 nodes are available: 1 node(s) had taint {node-role.kubernetes.io/master: }, that the pod didn't tolerate, 1 node(s) had taint {spray: mortein}, that the pod didn't tolerate.
07. Create another pod named bee with the nginx image, which has a toleration set to the taint mortein.
- Image name: nginx
- Key: spray
- Value: mortein
- Effect: NoSchedule
- Status: Running
# kubectl create -f <FILE-NAME>.yaml
---
apiVersion: v1
kind: Pod
metadata:
name: bee
spec:
containers:
- image: nginx
name: bee
tolerations:
- key: spray
value: mortein
effect: NoSchedule
operator: Equal
08. Notice the bee pod was scheduled on node node01 despite the taint.
09. Do you see any taints on controlplane node?
ask : Yes / NoSchedule
# 방법 1
kubectl describe nodes controlplane | grep -i taint
# 방법 2
root@controlplane:~# kubectl describe nodes controlplane
Name: controlplane
Roles: control-plane,master
Labels: beta.kubernetes.io/arch=amd64
beta.kubernetes.io/os=linux
kubernetes.io/arch=amd64
kubernetes.io/hostname=controlplane
kubernetes.io/os=linux
node-role.kubernetes.io/control-plane=
node-role.kubernetes.io/master=
Annotations: flannel.alpha.coreos.com/backend-data: {"VNI":1,"VtepMAC":"aa:9b:9e:0e:8e:e1"}
flannel.alpha.coreos.com/backend-type: vxlan
flannel.alpha.coreos.com/kube-subnet-manager: true
flannel.alpha.coreos.com/public-ip: 10.6.231.9
kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock
node.alpha.kubernetes.io/ttl: 0
volumes.kubernetes.io/controller-managed-attach-detach: true
CreationTimestamp: Wed, 19 Jan 2022 04:26:50 +0000
Taints: node-role.kubernetes.io/master:NoSchedule
Unschedulable: false
Lease:
HolderIdentity: controlplane
AcquireTime: <unset>
RenewTime: Wed, 19 Jan 2022 05:01:40 +0000
Conditions:
Type Status LastHeartbeatTime LastTransitionTime Reason Message
---- ------ ----------------- ------------------ ------ -------
NetworkUnavailable False Wed, 19 Jan 2022 04:27:15 +0000 Wed, 19 Jan 2022 04:27:15 +0000 FlannelIsUp Flannel is running on this node
MemoryPressure False Wed, 19 Jan 2022 04:57:34 +0000 Wed, 19 Jan 2022 04:26:41 +0000 KubeletHasSufficientMemory kubelet has sufficient memory available
DiskPressure False Wed, 19 Jan 2022 04:57:34 +0000 Wed, 19 Jan 2022 04:26:41 +0000 KubeletHasNoDiskPressure kubelet has no disk pressure
PIDPressure False Wed, 19 Jan 2022 04:57:34 +0000 Wed, 19 Jan 2022 04:26:41 +0000 KubeletHasSufficientPID kubelet has sufficient PID available
Ready True Wed, 19 Jan 2022 04:57:34 +0000 Wed, 19 Jan 2022 04:27:20 +0000 KubeletReady kubelet is posting ready status
Addresses:
InternalIP: 10.6.231.9
Hostname: controlplane
Capacity:
cpu: 36
ephemeral-storage: 507944172Ki
hugepages-1Gi: 0
hugepages-2Mi: 0
memory: 214588000Ki
pods: 110
Allocatable:
cpu: 36
ephemeral-storage: 468121348141
hugepages-1Gi: 0
hugepages-2Mi: 0
memory: 214485600Ki
pods: 110
System Info:
Machine ID: d950e0479f194b99a8e52fac3ff5469f
System UUID: d166a46b-93b8-00a7-bb41-46a9d410f6bc
Boot ID: bb0a8aca-8be4-4b03-8a40-7c17e89391c4
Kernel Version: 5.4.0-1060-gcp
OS Image: Ubuntu 18.04.5 LTS
Operating System: linux
Architecture: amd64
Container Runtime Version: docker://19.3.0
Kubelet Version: v1.20.0
Kube-Proxy Version: v1.20.0
PodCIDR: 10.244.0.0/24
PodCIDRs: 10.244.0.0/24
Non-terminated Pods: (8 in total)
Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits AGE
--------- ---- ------------ ---------- --------------- ------------- ---
kube-system coredns-74ff55c5b-jzvkd 100m (0%) 0 (0%) 70Mi (0%) 170Mi (0%) 34m
kube-system coredns-74ff55c5b-qf7lr 100m (0%) 0 (0%) 70Mi (0%) 170Mi (0%) 34m
kube-system etcd-controlplane 100m (0%) 0 (0%) 100Mi (0%) 0 (0%) 34m
kube-system kube-apiserver-controlplane 250m (0%) 0 (0%) 0 (0%) 0 (0%) 34m
kube-system kube-controller-manager-controlplane 200m (0%) 0 (0%) 0 (0%) 0 (0%) 34m
kube-system kube-flannel-ds-9h8bz 100m (0%) 100m (0%) 50Mi (0%) 300Mi (0%) 34m
kube-system kube-proxy-pw2wj 0 (0%) 0 (0%) 0 (0%) 0 (0%) 34m
kube-system kube-scheduler-controlplane 100m (0%) 0 (0%) 0 (0%) 0 (0%) 34m
Allocated resources:
(Total limits may be over 100 percent, i.e., overcommitted.)
Resource Requests Limits
-------- -------- ------
cpu 950m (2%) 100m (0%)
memory 290Mi (0%) 640Mi (0%)
ephemeral-storage 100Mi (0%) 0 (0%)
hugepages-1Gi 0 (0%) 0 (0%)
hugepages-2Mi 0 (0%) 0 (0%)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal NodeHasSufficientMemory 35m (x8 over 35m) kubelet Node controlplane status is now: NodeHasSufficientMemory
Normal NodeHasNoDiskPressure 35m (x8 over 35m) kubelet Node controlplane status is now: NodeHasNoDiskPressure
Normal NodeHasSufficientPID 35m (x7 over 35m) kubelet Node controlplane status is now: NodeHasSufficientPID
Normal Starting 34m kubelet Starting kubelet.
Normal NodeHasSufficientMemory 34m kubelet Node controlplane status is now: NodeHasSufficientMemory
Normal NodeHasNoDiskPressure 34m kubelet Node controlplane status is now: NodeHasNoDiskPressure
Normal NodeHasSufficientPID 34m kubelet Node controlplane status is now: NodeHasSufficientPID
Normal NodeAllocatableEnforced 34m kubelet Updated Node Allocatable limit across pods
Normal Starting 34m kube-proxy Starting kube-proxy.
Normal NodeReady 34m kubelet Node controlplane status is now: NodeReady
10. Remove the taint on controlplane, which currently has the taint effect of NoSchedule.
- Node name: controlplane
root@controlplane:~# kubectl delete nodes controlplane
node "controlplane" deleted
effect: "NoSchedule"
kubectl taint nodes node1 key1=value1:NoSchedule-
# 정답
kubectl taint nodes controlplane node-role.kubernetes.io/master:NoSchedule-
root@controlplane:~# kubectl taint nodes controlplane node-role.kubernetes.io/master:NoSchedule-
node/controlplane untainted
11. What is the state of the pod mosquito now?
ask : Running
root@controlplane:~# kubectl describe pod mosquito | grep -i state
State: Running
12. Which node is the POD mosquito on now?
ask : controlplane
root@controlplane:~# kubectl describe pod mosquito | grep -i node
Node: controlplane/10.8.117.6
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Warning FailedScheduling 2m34s (x9 over 9m40s) default-scheduler 0/2 nodes are available: 1 node(s) had taint {node-role.kubernetes.io/master: }, that the pod didn't tolerate, 1 node(s) had taint {spray: mortein}, that the pod didn't tolerate.
# Bookmark
https://kubernetes.io/ko/docs/concepts/scheduling-eviction/taint-and-toleration/
- 테인트 명령어 예제
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#taint
'CKA (Certified Kubernetes Administrator) > Kode Kloud' 카테고리의 다른 글
02.Scheduling - Resource Limits (0) | 2022.01.19 |
---|---|
02.Scheduling - Node Affinity (0) | 2022.01.19 |
02.Scheduling - Labels and Selectors (0) | 2022.01.19 |
02 Scheduling - Manual Scheduling (0) | 2022.01.19 |
01.CoreConcepts - Imperative Commands (0) | 2022.01.19 |