Taints
点是附加到节点上的一组键值对,用于指示节点的一些特性或者状态。污点可以防止不符合条件的 Pod 被调度到该节点上。
污点的格式为 key=value:effect
-
key:污点的键。
-
value:污点的值(可选)。
-
effect:污点的效果,可以是
NoSchedule、PreferNoSchedule或NoExecute。
污点的类型
-
NoSchedule:该节点不能调度新的 Pod,如果 Pod 不具有对应的容忍度。 -
PreferNoSchedule:该节点尽量不调度新的 Pod,但如果没有其他合适的节点,也可以调度。 -
NoExecute:该节点上已经运行的 Pod 将被驱逐,新的 Pod 不能调度到该节点上,除非 Pod 具有对应的容忍度。
#示例:
kubectl taint nodes node1 key=value:NoSchedule
查看污点
kubectl describe node node1 | grep Taints
删除污点
kubectl taint node node1key=value:NoSchedule-

tolerations: - key: "<key>" operator: "<operator>" value: "<value>" effect: "<effect>" tolerationSeconds: <seconds>
-
-
operator:操作符,通常是
Equal或Exists。 -
value:与节点污点的值匹配(可选)。
-
effect:污点的效果,可以是
NoSchedule、PreferNoSchedule或NoExecute。 -
tolerationSeconds:适用于
NoExecute
#示例 apiVersion: v1 kind: Pod metadata: name: my-pod spec: tolerations: - key: "key" operator: "Equal" value: "value" effect: "NoSchedule"
-
-
Pod 容忍度(Tolerations)
#示例:node节点污点 vim replicaset.yaml apiVersion: apps/v1 kind: ReplicaSet metadata: name: my-replicaset spec: replicas: 2 selector: matchLabels: app: myapp template: metadata: labels: app: myapp spec: nodeSelector: nodemaster: "yes" containers: - name: mycontainer image: harbor.hiuiu.com/nginx/nginx:1.21.5 imagePullPolicy: Never ports: - containerPort: 80 tolerations: - key: "disk-type" operator: "Equal" value: "IDE" effect: "NoSchedule" kubectl taint node hx5 disk-type=IDE:NoSchedule kubectl taint node hx6 disk-type=IDE:NoExecute kubectl describe node hx5 | grep Taints kubectl describe node hx6 | grep Taints kubectl apply -f replicaset.yaml kubectl get pod -o wide


浙公网安备 33010602011771号