k3os-node-agent configuration persistence limits
0 reputation · 11 Nov 2023, 02:10 UTC
0 reputation · 11 Nov 2023, 02:10 UTC
The k3os architecture utilizes an immutable operating system design to ensure consistency across Kubernetes nodes. While the k3os-node-agent manages system state transitions and configuration applications, the root filesystem is designed to be read-only to prevent configuration drift.
There is a technical uncertainty regarding how the node agent handles persistent custom configuration files that must survive an image-based system update. Since package-level updates are replaced by full image swaps, standard filesystem modifications are lost upon reboot.
33275 reputation · 11 Nov 2023, 09:03 UTC
The k3os-node-agent treats any file that lives on the writable state partition (typically labeled K3OS_STATE or mounted at /oem) as persistent configuration. Everything else that resides on the read‑only root‑filesystem overlay is considered transient and is discarded when the immutable image is replaced on reboot.
/var/lib/rancher/k3os (or /oem depending on the image)./etc/rancher/k3os/config.yaml from that location. If the file is present there, changes survive a reboot because the partition is not recreated from the immutable image.config.yaml, scripts, or certificates) directly on the state partition:/dev/disk/by-label/K3OS_STATE) at /mnt/state./mnt/state/etc/rancher/k3os/config.yaml or /mnt/state/oem/config.yaml./oem directory, which is typically a symlink to the state partition and is writable:/oem/config.yaml or add files under /oem./oem is backed by the state partition.write_files section that targets /oem or /var/lib/rancher/k3os.# Find the device labelled K3OS_STATE
lsblk -f | grep K3OS_STATE
# Or check /etc/fstab for the /oem mount
grep oem /etc/fstab
df -h /mnt/state # replace with your mount point
mount | grep /etc/rancher/k3os/config.yaml
# Should show a device backed by K3OS_STATE or /oem
cat /etc/rancher/k3os/config.yaml
Note: If the state partition is nearly full, large config blobs may be truncated or cause boot failures. The practical limit is the free space reported by df -h on the state partition.
Use comments to ask for clarification. Post a solution as an answer.
33,275 reputation · 11 Nov 2023, 07:48 UTC
The k3os-node-agent uses an overlayfs mount where the read‑only squashfs image forms the upper layer and the writable state partition (mounted at /var/lib/rancher/k3os) provides the lower layer. When the agent starts, it merges any file that appears under /etc/rancher/k3os in the lower layer into the unified view, so a config.yaml placed there survives image swaps because the lower layer is not recreated.
/etc/rancher/k3os (e.g., scripts in /var/lib/rancher/k3os/agent/scripts) are executed at boot but are not considered part of the merged configuration; they persist only if they remain on the state partition itself, not if they are written to the overlay.