Why do pods get evicted after 30 seconds when a node goes unreachable?
Pods are evicted 30 seconds after a node becomes unreachable because Syself Autopilot sets the default tolerations for the not-ready and unreachable node taints to 30 seconds. The Kubernetes default is 300 seconds. With 30 seconds, replicas on a failed node are replaced on healthy nodes sooner.
The 30 seconds start when Kubernetes marks the node NotReady or unreachable. Kubernetes does that after the node has missed its status updates for a grace period, so the eviction comes later than 30 seconds after the failure itself. A Deployment then starts the replacement pod on another node right away. A StatefulSet waits until the node comes back or is replaced. DaemonSet pods are not evicted.
The API server settings behind this are default-not-ready-toleration-seconds and default-unreachable-toleration-seconds. They are the same on every cluster and are not among the settings you can change (Can we change kube-apiserver settings?). You change the time per workload: set your own tolerations on the pods that have to stay longer.
tolerations:
- key: node.kubernetes.io/not-ready
operator: Exists
effect: NoExecute
tolerationSeconds: 300
- key: node.kubernetes.io/unreachable
operator: Exists
effect: NoExecute
tolerationSeconds: 300
Use this for pods that cannot move to another node, such as a database replica on a local disk. With a longer toleration, the node can come back from a short network outage and the pod keeps running. For more on such pods, see Keep stateful pods safe across node replacement.
The eviction only moves the pods. Rebooting or replacing the node is a separate step, which Syself Autopilot does on its own: see Does Syself Autopilot replace a failed node on its own? The exact conditions are in Machine health checks and remediation.
Related questions
