k8s 指定节点调度标签
生活随笔
收集整理的這篇文章主要介紹了
k8s 指定节点调度标签
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?nodeSelector 強制匹配
?指定pod 調度到標簽 ssd
[root@k8s-master cka3]# cat ssd.yaml apiVersion: v1 kind: Pod metadata:name: nginx-kusc00401 spec:containers:- name: nginximage: nginximagePullPolicy: IfNotPresentnodeSelector:disktype: ssd?這里顯示親和性不夠
?
?我們現在給節點加上標簽:kubectl label nodes <node-name>? <node-key>=<label-value>
[root@k8s-master cka3]# kubectl label nodes k8s-node2 disktype=ssd node/k8s-node2 labeled?再次查看調度成功
?-----------------------------------------------------------------------------------------------------------------------------
刪除標簽:
[root@k8s-master cka3]# kubectl label node k8s-node2 disktype- node/k8s-node2 labeled-------------------------------------------------------------------------------------------------------------------------------
nodeAffinity: 調度分為軟性:嘗試滿足,但不保證(preferred)? 硬性:一定滿足 (required)
[root@k8s-master cka3]# cat test.yaml apiVersion: v1 kind: Pod metadata:name: with-node-affinity spec:affinity:nodeAffinity:requiredDuringSchedulingIgnoredDuringExecution:nodeSelectorTerms:- matchExpressions:- key: disktypeoperator: Invalues:- ssdpreferredDuringSchedulingIgnoredDuringExecution:- weight: 1preference:matchExpressions:- key: disktypeoperator: Invalues:- ssd2containers:- name: with-node-affinityimage: nginx軟匹配不一定成功
?
?
總結
以上是生活随笔為你收集整理的k8s 指定节点调度标签的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 快速建立Typecho博客网站
- 下一篇: uniapp 本地缓存剩余时间