|NO.Z.00207|——————————|CloudNative|——|KuberNetes&高级调度.V10|——|Affinity.v02|Affinity实验二:NotIn|

一、实验二:NotIn:
### --- pod不要部署在满足这些条件的节点上

~~~     # 把pod部署在label不要部署在 kubernetes.io/e2e-az-name;values:
~~~     是- e2e-az1和- e2e-az2节点上面。
~~~     # 这样它就会部署在具有这个label的节点上面- key: another-node-label-key;
~~~     values:- another-node-label-value
[root@k8s-master01 ~]# kubectl edit deploy demo-nginx
    spec:
      affinity:
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - preference:
              matchExpressions:
              - key: another-node-label-key
                operator: In
                values:
                - another-node-label-value
            weight: 1
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: kubernetes.io/e2e-az-name
                operator: NotIn     # 把In改成NoIn,就是不要部署在具有这个标签的节点上面
                values:
                - e2e-az1
                - e2e-az2
### --- 可以看到部署在了k8s-master01上面,因为master01上是有那个标签的,
~~~     所以他一定会在master01上部署一个

[root@k8s-master01 ~]# kubectl get po -owide
NAME                          READY   STATUS        RESTARTS   AGE     IP               NODE           NOMINATED NODE   READINESS GATES
busybox                       1/1     Running       6          17h     172.25.244.247   k8s-master01   <none>           <none>
demo-nginx-65dbbcc544-9b6jr   2/2     Running       0          8s      172.25.244.194   k8s-master01   <none>           <none>
demo-nginx-65dbbcc544-cv5nw   2/2     Running       0          8s      172.25.244.255   k8s-master01   <none>           <none>
demo-nginx-79cc4bc-f8crn      0/2     Terminating   0          7m12s   <none>           k8s-node01     <none>           <none>
demo-nginx-79cc4bc-h8f9b      0/2     Terminating   0          7m12s   <none>           k8s-node01     <none>  

 
 
 
 
 
 
 
 
 

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  阅读(134)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
< 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

导航

统计

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