[kubernetes集群调度] - ② 调度亲和性
2021-02-18 16:18
标签:note nta pod 拓扑 index ssi 支持 container hostname [kubernetes集群调度] - ② 调度亲和性 标签:note nta pod 拓扑 index ssi 支持 container hostname 原文地址:https://www.cnblogs.com/uvwill/p/12940478.html节点亲和性
pod.spec.nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
apiVersion: v1
kind: Pod
metadata:
name: affinity
labels:
app: node-affinity-pod
spec:
containers:
- name: with-node-affinity
image: hub.atguigu.com
/library/myapp
:v1
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io
/hostname
operator: NotIn
values:
- k8s-node02
preferredDuringSchedulingIgnoredDuringExecution:
apiVersion: v1
kind: Pod
metadata:
name: affinity
labels:
app: node-affinity-pod
spec:
containers:
- name: with-node-affinity
image: hub.atguigu.com
/library/myapp
:v1
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key:
source
operator: In
values:
- qikqiak
合体
apiVersion: v1
kind: Pod
metadata:
name: affinity
labels:
app: node-affinity-pod
spec:
containers:
- name: with-node-affinity
image: hub.atguigu.com
/library/myapp
:v1
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io
/hostname
operator: NotIn
values:
- k8s-node02
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key:
source
operator: In
values:
- qikqiak
键值运算关系
Pod 亲和性
pod.spec.affinity.podAffinity/podAntiAffinity
apiVersion: v1
kind: Pod
metadata:
name: pod-3
labels:
app: pod-3
spec:
containers:
- name: pod-3
image: hub.atguigu.com
/library/myapp
:v1
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- pod-1
topologyKey: kubernetes.io
/hostname
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAffinityTerm:
labelSelector: matchExpressions:
- key: app
operator: In
values: - pod-2
topologyKey: kubernetes.io
/hostname
亲和性/反亲和性调度策略比较如下:
调度策略
操作符
拓扑域支持
调度目标
nodeAffinity
主机
否
指定主机
podAffinity
POD
是
podAnitAffinity
POD
是
下一篇:何为ajax
文章标题:[kubernetes集群调度] - ② 调度亲和性
文章链接:http://soscw.com/index.php/essay/57120.html