|NO.Z.00208|——————————|CloudNative|——|KuberNetes&高级调度.V11|——|Affinity.v03|Affinity实验三:Exists|

一、实验三:
### --- Exists:部署在具有某个存在key为指定的值的Node节点上
~~~     配置Exists参数

[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: kubernetes.io/e2e-az-name
                operator: Exists    
### --- 部署在node节点上面有这个label,而且这个label的key是这个节点上面。value不需要写
~~~     可以看到它的这个值部署在了k8s-node02节点上面,
~~~     有这个key的话他会部署在这个节点上面,这是强一致性的。
~~~     若是没有这个key的话就会处于pending状态

[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-cv5nw   2/2     Running             0          88s   172.25.244.255   k8s-master01   <none>           <none>
demo-nginx-84c57d4448-2xwcx   0/2     ContainerCreating   0          18s   <none>           k8s-node01     <none>           <none>
demo-nginx-84c57d4448-x6nv5   0/2     ContainerCreating   0          18s   <none>           k8s-node01     <none>           <none>         <none>
### --- 删除这个label验证是否显示为pending状态

[root@k8s-master01 ~]# kubectl label node k8s-node01 k8s-node02 kubernetes.io/e2e-az-name-
node/k8s-node01 labeled
node/k8s-node02 labeled
### --- 显示pending状态了 

[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-84c57d4448-gsqh5   0/2     Pending       0          81s    <none>           <none>         <none>           <none>
demo-nginx-84c57d4448-hflwk   0/2     Pending       0          8s     <none>           <none>         <none>           <none>
demo-nginx-84c57d4448-x6nv5   0/2     Terminating   0          9m7s   <none>           k8s-node01     <none>           <none> 
demo-nginx-84c57d4448-2xwcx   0/2     Terminating   0          8m36s   <none>           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  阅读(36)  评论(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

导航

统计

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