|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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了