Kubernetes Node污点

kubectl taint nodes 192.168.204.129 key1=value1:NoExecute
node/192.168.204.129 tainted

如果不指定key,那么可以使用

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-hello-deployment3
  namespace: lizhe
  labels:
    app: nginx-hello3
spec:
  replicas: 6
  selector:
    matchLabels:
      app: nginx-hello3
  template:
    metadata:
      labels:
        app: nginx-hello3
    spec:
      tolerations:
      - effect: NoExecute
        operator: Exists
      containers:
      - name: nginx-hello3
        image: nginx
        ports:
        - containerPort: 80

这样会忽略所有 key

可以看到 nginx3 运行在了 129上

如果需要指定特定的 key ,例如这里指定 key = key2 ,实际上这个 key2 不存在,所以是没有任何容忍的

    spec:
      tolerations:
      - effect: NoExecute
        operator: Exists
        key: key2

也可以加入 value 但是就无法使用 operator 了

The Deployment "nginx-hello-deployment3" is invalid: spec.template.spec.tolerations[0].operator: Invalid value: core.Toleration{Key:"key1", Operator:"Exists", Value:"value2", Effect:"NoExecute", TolerationSeconds:(*int64)(nil)}: value must be empty when `operator` is 'Exists'
    spec:
      tolerations:
      - effect: NoExecute
        key: key1
        value: value2

如果想容忍的话

    spec:
      tolerations:
      - effect: NoExecute
        key: key1
        value: value1
Send a Message