|NO.Z.00202|——————————|CloudNative|——|KuberNetes&高级调度.V05|——|污点容忍.v03|NoSchedule静止调度容器强制驱逐|

一、NoSchedule静止调度,容器强制驱逐
### --- 为master01打一个污点,NoSchedule类型,静止调度;容器会被强制驱逐
~~~     为master01节点打入污点,NoExecute类型

[root@k8s-master01 ~]# kubectl taint node k8s-master01 master-test=test:NoExecute
node/k8s-master01 tainted
### --- 可以看到master01节点上的被强制迁移
~~~     在k8s-master01节点的先是Terminating状态的被删除掉
~~~     Pending状态因为我们为容器打了NoSchedule状态,它只能部署在k8s-master01节点,
~~~     所以它会显示Pending状态  

[root@k8s-master01 ~]# kubectl get po -owide
NAME                          READY   STATUS        RESTARTS   AGE     IP               NODE           NOMINATED NODE   READINESS GATES
busybox                       1/1     Terminating   126        9d      172.25.244.211   k8s-master01   <none>           <none>
demo-nginx-6fddc76f8d-6n88v   0/2     Pending       0          10s     <none>           <none>         <none>           <none>
demo-nginx-6fddc76f8d-9cjzb   2/2     Terminating   0          7m28s   172.25.244.229   k8s-master01   <none>           <none>
demo-nginx-6fddc76f8d-jd65q   0/2     Pending       0          10s     <none>           <none>         <none>           <none>
二、删除一个污点
### --- 删除一个污点
~~~     查看k8s-master01所有的污点
~~~     注:只有它的key、value、effect都一样的,才能被认为是同一个污点
~~~     所以我们删的时候需要把key名和effect指定在上面才可以被删除掉

[root@k8s-master01 ~]# kubectl describe node k8s-master01
 Taints:             master-test=test:NoExecute
                    master-test=test:NoSchedule
### --- 删除一个污点

[root@k8s-master01 ~]# kubectl taint node k8s-master01 master-test:NoExecute-
node/k8s-master01 untainted
You have new mail in /var/spool/mail/root
### --- 查看污点;发现删除的污点已经不存在了

[root@k8s-master01 ~]# kubectl describe node k8s-master01
Taints:             master-test=test:NoSchedule
### --- 查看k8s-master01上的两个pod运行正常;不在是pending状态。

[root@k8s-master01 ~]# kubectl get po -owide
NAME                          READY   STATUS      RESTARTS   AGE     IP               NODE           NOMINATED NODE   READINESS GATES
demo-nginx-6fddc76f8d-6n88v   2/2     Running     0          8m28s   172.25.244.231   k8s-master01   <none>           <none>
demo-nginx-6fddc76f8d-jd65q   2/2     Running     0          8m28s   172.25.244.230   k8s-master01   <none>           <none>
三、注释说明
### --- 污点类型

~~~     NoSchedule:禁止调度
~~~     NoExecute:如果不符合这个污点,会立马被驱逐
~~~     PreferNoSchedule: 尽量避免将Pod调度到指定的节点上。
~~~     node.kubernetes.io/not-ready: 节点没有准备好,Ready不为true
### --- tolerations的书写规则

      tolerations:
      - effect: NoSchedule
        key: master-test
        operator: Equal
        value: test
### --- Node节点有多个Taint,每个Taint都需要容忍才能部署上去。
~~~     注:可以容忍key:master-test,effect:NoSchedule的,不管它的value是什么都可以容忍。
~~~     注:只要匹配到了key和effect都是可以容忍,不管value是什么

      tolerations:
      - effect: NoSchedule
        key: master-test
        operator: Exists
### --- 可以容忍所有的污点
~~~     注:可以容忍所有的污点,没有写key和effect;一般是用不到的

      tolerations:
      - operator: Exists
### --- 容忍2个污点。
~~~     注:只要它的污点只要存在这个key,我都可以去容忍,这样就可以简单的容忍2个effect。 

      tolerations:
      - operator: Exists
        key: master-test        

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on   yanqi_vip  阅读(64)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示