[애플리케이션 스케줄링과 라이프사이클 관리] 테인트를 활용한 스케줄링 실습

hi·2023년 8월 8일
0

쿠버네티스

목록 보기
49/64
post-custom-banner
controlplane ~ ➜  k get node
NAME           STATUS   ROLES           AGE   VERSION
controlplane   Ready    control-plane   14m   v1.27.0
node01         Ready    <none>          14m   v1.27.0
controlplane ~ ✖ k describe node node01 | grep Taints
Taints:             <none>
controlplane ~ ✖ kubectl taint nodes node01 spray=mortein:NoSchedule
node/node01 tainted

controlplane ~ ➜  kubectl run mosquito --image=nginx
pod/mosquito created

controlplane ~ ➜  k get pod
NAME       READY   STATUS    RESTARTS   AGE
mosquito   0/1     Pending   0          4s
controlplane ~ ➜  k describe pod mosquito
Name:             mosquito
Namespace:        default
Priority:         0
Service Account:  default
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 kube-api-access-fjrrx (ro)
Conditions:
  Type           Status
  PodScheduled   False 
Volumes:
  kube-api-access-fjrrx:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
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  73s   default-scheduler  0/2 nodes are available: 1 node(s) had untolerated taint {node-role.kubernetes.io/control-plane: }, 1 node(s) had untolerated taint {spray: mortein}. preemption: 0/2 nodes are available: 2 Preemption is not helpful for scheduling..ca

temp.yaml

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: bee
  name: bee
spec:
  containers:
  - image: nginx
    name: bee
    resources: {}
  tolerations:
  - key: "spray"
    operator: "Equal"
    value: "mortein"
    effect: "NoSchedule"
controlplane ~ ➜  k create -f temp.yaml
pod/bee created

controlplane ~ ➜  k get pod
NAME       READY   STATUS    RESTARTS   AGE
bee        1/1     Running   0          10s
mosquito   0/1     Pending   0          5m45s

Remove the taint on controlplane, which currently has the taint effect of NoSchedule.

controlplane ~ ➜  k describe node controlplane | grep Taints
Taints:             node-role.kubernetes.io/control-plane:NoSchedule
controlplane ~ ➜  kubectl taint nodes controlplane node-role.kubernetes.io/control-plane:NoSchedule-node/controlplane untainted

What is the state of the pod mosquito now?

controlplane ~ ✖ kubectl get pod -o wide
NAME       READY   STATUS    RESTARTS   AGE   IP           NODE           NOMINATED NODE   READINESS GATES
bee        1/1     Running   0          12m   10.244.1.2   node01         <none>           <none>
mosquito   1/1     Running   0          17m   10.244.0.4   controlplane   <none>           <none>
post-custom-banner

0개의 댓글