-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathpod_affinityNode.yaml
31 lines (31 loc) · 1.32 KB
/
pod_affinityNode.yaml
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
apiVersion: v1
kind: Pod
metadata:
name: go-http-nodeAffinity
labels:
app: go
version: v1
spec:
containers:
- name: go-http
image: leigg/hellok8s:v1
# nodeSelector: 如果和亲和性同时配置,则必须都满足
affinity:
nodeAffinity: # 不会绕过污点机制
# 下面两项可以二选一,也可以同时存在
# - requiredDuringSchedulingIgnoredDuringExecution
# - preferredDuringSchedulingIgnoredDuringExecution
requiredDuringSchedulingIgnoredDuringExecution: # 硬性调度
nodeSelectorTerms: # 多个 matchExpressions 之间的关系是【或】关系
- matchExpressions: # 单个 matchExpressions 中的多个表达式是【且】关系
# operator 支持 In、NotIn、Exists、DoesNotExist、Gt 和 Lt,其中NotIn和DoesNotExist可用于实现节点反亲和性
- {key: disktype, operator: In, values: ["ssd"]}
# preferredDuringSchedulingIgnoredDuringExecution: # 软性调度
# - weight: 1 # 相比其他 软性调度 策略的权重,范围是1-100
# preference:
# - matchExpressions:
# - { key: disktype, operator: In, values: [ "ssd" ] }
# - weight: 5
# preference:
# - matchExpressions:
# - { key: cpu, operator: In, values: [ "4core" ] }