污点与容忍度如果Node节点上有污点需要Pod有容忍度才能调度运行污点Taints定义在节点上用于拒绝Pod调度到此节点除非该Pod具有该节点上的污点容忍度。被标记有Taints的节点并不是故障节点。容忍度Tolerations定义在Pod上用于配置Pod可容忍的节点污点K8S调度器只能将Pod调度到该Pod能够容忍的污点的节点上。调度示例图污点的三种排斥级别NoSchedule:没有容忍度的Pod不能新建已经运行的Pod不受影响PreferNoSchedule没有容忍度Pod尽量不要创建如果没有其他节点可以选择也能创建NoExecute驱逐所有Pod应用给Node打污点#创建污点 kubectl taint nodes node1 aihaoshuijiao:NoSchedule #删除污点 kubectl taint nodes node1 aihao- kubectl taint nodes node1 exidubo:NoExecute kubectl taint nodes node1 exi- #删除master上的污点 kubectl taint node master node-role.kubernetes.io/master-给Pod添加容忍度kubectl taint nodes node2 aihaochifan: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: NoSchedulevim 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