污点和容忍度
node节点的亲和性
node节点亲和性调度:nodeAffinity
kubectl explain pods.spec.affinity.nodeAffinity
preferredDuringSchedulingIgnoredDuringExecution:软亲和性,尽可能的满足
requiredDuringSchedulingIgnoredDuringExecution:硬亲和性,必须满足
1、使用硬亲和性测试
vim pod-nodeaffinity-demo.yaml
apiVersion: v1
kind: Pod
metadata:
name: pod-node-affinity-demo
namespace: default
labels:
app: myapp
tier: frontend
spec:
containers:
- name: myapp
image: ikubernetes/myapp:v1
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: zone
operator: In
values:
- foo
- bar
我们检查当前节点中任意一个节点拥有zone标签的值是foo或者bar,就可以把pod调度到这个node节点的foo或者bar标签上的节点上
没有定义zone=foo或者zone=bar标签,所以无法找到,会报错
kubectl label node node01 zone=foo
kubectl apply -f pod-nodeaffinity-demo.yaml
2、使用软亲和性测试
vim pod-nodeaffinity-demo-2.yaml
apiVersion: v1
kind: Pod
metadata:
name: pod-node-affinity-demo-2
namespace: default
labels:
app: myapp
tier: frontend
spec:
containers:
- name: myapp
image: ikubernetes/myapp:v1
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- preference:
matchExpressions:
- key: zone1
operator: In
values:
- foo1
- bar1
weight: 60
创建
kubectl apply -f pod-nodeaffinity-demo-2.yaml
虽然没有zone1=foo1标签,但是一样会调度,这就是软亲和性
node节点亲和性针对的是pod和node的关系。pod调度到node节点的时候匹配的条件。
来张图片镇楼
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。