feat(host): start k3s only after the clock is synchronized

The desktop dual-boots Windows, which writes local time (KST) to the
RTC, while Ubuntu reads the RTC as UTC. On 2026-11-11 the boot started
9 hours ahead; k3s issued its certificates at that time, timesyncd
then set the clock back, the certificates were not yet valid, and
every Ingress returned 502 until k3s was restarted by hand.

Add a k3s.service drop-in with Wants= and After=time-sync.target, and
a drop-in that caps systemd-time-wait-sync.service at 10 minutes.
Enabling systemd-time-wait-sync makes time-sync.target wait for the
first NTP sync; its packaged TimeoutStartSec=infinity would keep k3s
down forever when NTP is unreachable, so after 10 minutes it fails,
the target is reached anyway and k3s starts as it does today.

Risk: the order only applies at boot, so nothing changes until the
next reboot. If NTP is down at boot, k3s starts 10 minutes later. The
Windows side still writes local time until RealTimeIsUniversal is set
there; the host guide covers that step.

Verification: systemd-analyze verify passes for k3s.service and
systemd-time-wait-sync.service with the drop-ins, and an unknown key
added to each drop-in is reported, so both files are read.
This commit is contained in:
DongHyeonka
2026-11-12 07:28:03 +09:00
parent a5f0bff26e
commit 03ed6719b0
2 changed files with 14 additions and 0 deletions
@@ -0,0 +1,9 @@
# Start k3s only after the system clock is synchronized.
# k3s writes certificates with the current time at start. If the clock is
# wrong at boot (RTC read 9 hours ahead on 2026-11-11) and NTP corrects it
# later, those certificates are "not yet valid" and every Ingress returns 502.
# time-sync.target is reached only when systemd-time-wait-sync.service is
# enabled. See infrastructure/host/README.md.
[Unit]
Wants=time-sync.target
After=time-sync.target
@@ -0,0 +1,5 @@
# The packaged unit waits forever (TimeoutStartSec=infinity). If NTP is not
# reachable at boot, k3s would never start. After 10 minutes this unit fails,
# time-sync.target is reached anyway, and k3s starts with the clock it has.
[Service]
TimeoutStartSec=10min