污点与容忍度
如果Node节点上有污点,需要Pod有容忍度才能调度运行;
·
污点与容忍度
如果Node节点上有污点,需要Pod有容忍度才能调度运行;
- 污点(Taints):定义在节点上,用于拒绝Pod调度到此节点,除非该Pod具有该节点上的污点容忍度。被标记有Taints的节点并不是故障节点。
- 容忍度(Tolerations):定义在Pod上,用于配置Pod可容忍的节点污点,K8S调度器只能将Pod调度到该Pod能够容忍的污点的节点上。
- 调度示例图:

污点的三种排斥级别
- NoSchedule:没有容忍度的Pod不能新建,已经运行的Pod不受影响;
- PreferNoSchedule:没有容忍度Pod尽量不要创建,如果没有其他节点可以选择,也能创建;
- NoExecute:驱逐所有Pod应用;
给Node打污点
#创建污点
kubectl taint nodes node1 aihao=shuijiao:NoSchedule
#删除污点
kubectl taint nodes node1 aihao-
kubectl taint nodes node1 exi=dubo:NoExecute
kubectl taint nodes node1 exi-
#删除master上的污点
kubectl taint node master node-role.kubernetes.io/master-


给Pod添加容忍度
kubectl taint nodes node2 aihao=chifan:NoSchedule
vim 18.taint-test2.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: myapp-new
name: myapp-new
spec:
replicas: 10
selector:
matchLabels:
app: myapp-new
template:
metadata:
labels:
app: myapp-new
spec:
containers:
- image: nginx:1.24
name: nginx
tolerations:
- key: "aihao"
operator: "Equal"
value: "shuijiao"
effect: "NoSchedule"

vim 18.taint-test2.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: myapp-new
name: myapp-new
spec:
replicas: 10
selector:
matchLabels:
app: myapp-new
template:
metadata:
labels:
app: myapp-new
spec:
containers:
- image: nginx:1.24
name: nginx
tolerations:
- key: "aihao"
operator: "Exists"
effect: "NoSchedule"

更多推荐



所有评论(0)