k3os and systemd: What is the impact of kubelet's stop timeout on pod termination?
0 reputation · 30 Oct 2025, 13:05 UTC
0 reputation · 30 Oct 2025, 13:05 UTC
The goal is to understand how the stop timeout configured in the kubelet.service unit influences the termination of running pods when a k3os node is powered down or reset. In k3os the kubelet is launched as a systemd service with TimeoutStopSec=0 by default, meaning that a SIGTERM is followed immediately by a SIGKILL. This can leave stateful workloads in an indeterminate state, potentially causing data corruption.
Constraints include the fact that the timeout is not exposed as a k3os CLI flag, and that systemd overrides may be lost during upgrades. The uncertainty lies in whether k3os should automatically set a non‑zero stop timeout or provide a higher‑level configuration option.
Given these conditions, we need to clarify:
TimeoutStopSec value on a fresh k3os installation, and how does it change after a reset or upgrade?35775 reputation · 31 Oct 2025, 00:52 UTC
On a fresh k3os installation, the kubelet.service unit file contains TimeoutStopSec=0. When the node is powered down or reset, systemd sends SIGTERM to the kubelet process, waits zero seconds, then sends SIGKILL. This happens regardless of whether pods are still terminating.
terminationGracePeriodSeconds.TimeoutStopSec=0, systemd does not wait. Within milliseconds, it sends SIGKILL to the kubelet.Run these commands on your k3os node to confirm the current state:
# Check current timeout setting
systemctl show kubelet -p TimeoutStopUSec
# Watch kubelet logs during a controlled shutdown
journalctl -u kubelet -f
# From a control plane node, monitor pod termination
kubectl get pods -A --field-selector spec.nodeName=$(hostname) -w
The practical solution is to set TimeoutStopSec to a value that accommodates the longest-running pod in your cluster. A typical default of 120–300 seconds works for most workloads.
sudo systemctl edit kubelet
This opens an editor. Add the following content:
[Service]
TimeoutStopSec=180
The override is written to /etc/systemd/system/kubelet.service.d/override.conf. However, k3os may overwrite unit files during upgrades. To preserve this setting across upgrades, add it to /oem/override.yaml:
systemd:
units:
- name: kubelet.service
dropin:
Service:
TimeoutStopSec: 180
Stateful workloads—databases, message queues, file stores—rely on graceful shutdown to flush data and close connections cleanly. A zero timeout bypasses all of this, increasing the risk of data corruption or inconsistent state. Additionally, pod disruption budgets may be violated if pods are force-killed before their defined disruption policies allow.
If you have workloads with unusually long pre-stop hooks (e.g., backup operations before shutdown), you may need to increase the timeout further. Check your pod specs for terminationGracePeriodSeconds and add a safety margin.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.