daemonset

201 阅读1分钟

污点

查看污点

kubectl describe node k8s-master

示范增加一个 taint 到 node 上的操作:

kubectl taint nodes tvm-04 demo.test.com/app=whoami:NoSchedule
kubectl taint nodes k8s-master node-role.kubernetes.io/master=:NoSchedule

在节点 tvm-04 上配置了一个 taint ,其中:
keydemo.test.com/app
valuewhoami
taint effectNoSchedule

      NoSchedule: 一定不能被调度
      PreferNoSchedule: 尽量不要调度
      NoExecute: 不仅不会调度, 还会驱逐Node上已有的Pod

如果要移除 taint 则:

kubectl taint nodes tvm-04 demo.test.com/app:NoSchedule-

然后在 PodSpec 中定义 toleration 使得该 pod 可以被调度到 tvm-04 上,有下述 2 种方式:

tolerations:
- key: "demo.test.com/app"   #不指定key值容忍所有污点
  operator: "Equal"  
  value: "whoami"  
  effect: "NoSchedule" #不指定时,容忍所有作用

tolerations:
- key: "demo.test.com/app"  
  operator: "Exists"  #operator的值为Exists将会忽略value值
  effect: "NoSchedule"
  tolerationSeconds: 3000s #用于描述当 Pod 需要被驱逐时可以在 Pod 上继续保留运行的时间
  • Kubernetes 1.6 或者更高版本中才支持 DaemonSet 滚动更新功能。

首先 terminationGracePeriodSeconds 要设置一个合适的值,至少保证所有现存的request能被正确处理并返回你的程序需要处理SIGTERM信号,并且保证所有事务完成后再关闭程序。