|NO.Z.00209|——————————|CloudNative|——|KuberNetes&高级调度.V12|——|Affinity.v04|Affinity实验三:Gt|

一、实验四:
### --- Gt: 大于指定的条件  条件为number,不能为字符串
~~~     打标签

[root@k8s-master01 ~]# kubectl label node k8s-node01 test.gt=a
node/k8s-node01 labeled
[root@k8s-master01 ~]# kubectl label node k8s-node02 test.gt=f
node/k8s-node02 labeled
~~~     # 修改label定义为数字

[root@k8s-master01 ~]# kubectl label node k8s-node01 test.gt=20 --overwrite
node/k8s-node01 labeled
[root@k8s-master01 ~]# kubectl label node k8s-node02 test.gt=10 --overwrite
node/k8s-node02 labeled
### --- 修改配置参数
~~~     定义值为15,它会部署在node02上面,因为只有node01的值符合条件,大于15

[root@k8s-master01 ~]# kubectl edit deploy demo-nginx
      affinity:
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - preference:
              matchExpressions:
              - key: another-node-label-key
                operator: In
                values:
                - another-node-label-value
            weight: 1
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: test.gt
                operator: Gt
                values:
                - "15"  
~~~     # 可以看到它部署在node01上面,因为只有node01的标签值大于15   

[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-5d5cd5d6f6-7wd7g   2/2     Running   0          47s   172.17.125.33    k8s-node01     <none>           <none>
demo-nginx-5d5cd5d6f6-8stw4   2/2     Running   0          46s   172.17.125.34    k8s-node01     <none>           <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  阅读(31)  评论(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

导航

统计

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