Taints
点是附加到节点上的一组键值对,用于指示节点的一些特性或者状态。污点可以防止不符合条件的 Pod 被调度到该节点上。
污点的格式为 key=value:effect
-
key:污点的键。
-
value:污点的值(可选)。
-
effect:污点的效果,可以是
NoSchedule
、PreferNoSchedule
或NoExecute
。
污点的类型
-
NoSchedule
:该节点不能调度新的 Pod,如果 Pod 不具有对应的容忍度。 -
PreferNoSchedule
:该节点尽量不调度新的 Pod,但如果没有其他合适的节点,也可以调度。 -
NoExecute
:该节点上已经运行的 Pod 将被驱逐,新的 Pod 不能调度到该节点上,除非 Pod 具有对应的容忍度。
#示例:=value:NoSchedule
kubectl taint nodes node1 key
查看污点
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: mypod 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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了