K3s集群中node节点宕机后其上的pod不会立即转移
1、说明
搭建完成k3s集群后,为了测试k3s集群的性能。选择直接将node关机,查看对应的pod有没有转移。
经过一通操作之后发现 rancher集群上显示关闭的node对应的pod转态变为Unknow,但是没有新建出pod。这是怎么回事儿呢?
2、原因
一通google之后,找到了参考链接中的说法。
在 Kubernetes v1.13 版本中,TaintBasedEvictions
特性是默认开启的。请查阅 Kubernetes: Taint based Evictions 获取更多信息。
-
kube-apiserver (Kubernetes v1.13 版本及以后)
-
default-not-ready-toleration-seconds
: 表示 notReady:NoExecute 容忍的容忍时间。notReady:NoExecute 被默认添加到没有该容忍的所有 Pod。 -
default-unreachable-toleration-seconds
: 表示 unreachable:NoExecute 容忍的容忍时间。unreachable:NoExecute 被默认添加到没有该容忍的所有 Pod。
-
原来是自kubernetes v1.13版本后默认设置了pod转移时间。
3、更改默认pod的转移时间
k3s官方提供了实例文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: busybox-deployment
labels:
app: busybox
spec:
replicas: 3
selector:
matchLabels:
app: busybox
template:
metadata:
labels:
app: busybox
spec:
########################
tolerations:
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 2
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 2
####################################
containers:
- name: busybox
image: busybox
args:
- sleep
- "1000000"
以上####中间的部分为设置容忍时间,也就是持续对应转态多长时间后开始重新构建。