10 Commits
Author SHA1 Message Date
DongHyeonka c04d79481c docs(host): point the time-sync step at the k3s restart bundle
scripts/bootstrap/apply-k3s-restart-bundle.sh now installs the two
time-sync drop-ins and enables systemd-time-wait-sync together with the
kubelet drop-ins, so the owner restarts k3s once. Say so in step 2 and
keep the manual commands for installing only these two files.
2026-11-12 07:36:11 +09:00
DongHyeonka fb5535aeb6 docs(host): add the owner steps for the desktop host settings
The host files need root, so agent sessions do not install them. The
owner needs one ordered list with checks and rollback for each step,
including when a Docker restart is safe.

Add infrastructure/host/README.md: why the disk and clock settings
exist, the BuildKit key meanings in Docker 29, and four steps. Pin the
tech-log images against kubelet image GC until they move to the Gitea
registry, install the k3s time-sync drop-ins, set the RTC to UTC on
the Windows side, and install the host daemon.json during a window
with no CI job, no agent gate holding the heavy lock, and workmachine
not in use.

Risk: the image pin is a manual label on the current tags; a new
deployment tag needs the label again until the registry move lands.

Verification: the commands were checked on the desktop where they do
not need root (systemctl show, timedatectl, docker buildx inspect,
docker exec gitea-runner docker ps); the sudo steps were not run.
2026-11-12 07:28:03 +09:00
DongHyeonka 03ed6719b0 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.
2026-11-12 07:28:03 +09:00
DongHyeonka 3bca2cf841 feat(host): cap the host Docker build cache
The host Docker daemon had no daemon.json. The default BuildKit policy
on this 228GiB disk keeps 21.42GiB of build cache untouched and allows
169.5GiB (docker buildx inspect default), so agent gate builds piled
up about 23G in two days before the 2026-11-09 disk incident.

Add infrastructure/host/docker/daemon.json with builder.gc
defaultReservedSpace 5GB, defaultMaxUsedSpace 15GB and
defaultMinFreeSpace 35GB. In Docker 29 the old defaultKeepStorage key
means defaultReservedSpace, a floor and not a cap, so the cap is
defaultMaxUsedSpace. 35GiB free is about 85% use, where the kubelet
starts deleting images; below it the cache shrinks to the floor first.
Moving the Docker data root to the HDD was rejected by the owner
because builds get slower.

Risk: applying needs sudo and a Docker restart, which restarts the
runner, workmachine and cloudflared and fails running CI jobs and
gates. The host apply guide added in this series says when that is
safe. dockerd --validate does not check keys inside builder.gc, so
the guide checks the live policy with docker buildx inspect.

Verification: dockerd --validate passes for the file on Docker
29.6.1; it also passes a typo inside builder.gc and rejects an unknown
top-level key, which is why the live check is in the guide.
2026-11-12 07:28:03 +09:00
donghyeon.kang 8b019d26a0 Merge pull request 'docs(runbooks): add restore, rebuild, upgrade and reboot runbooks' (#8) from donghyeon.kang/w6-runbooks into main 2026-11-11 16:48:53 +00:00
donghyeon.kang 00a6680b76 Merge pull request 'feat(backup): back up k3s and Gitea to AIStor with alerts and drills' (#6) from donghyeon.kang/w6-host-backups into main 2026-11-11 16:48:31 +00:00
DongHyeonka 96623200fa feat(host): keep the k3s nodeport-loopback drop-in in the repository
/etc/rancher/k3s/config.yaml.d/30-nodeport-loopback.yaml keeps Traefik's
NodePorts on 127.0.0.0/8 so the LAN cannot bypass Host Nginx. The
Traefik README and validator depend on it, but the file itself was only
on the host, so a rebuilt host would not get it.

Add the live content as is (kube-proxy-arg nodeport-addresses). The
host-rebuild and datastore-restore runbooks install it.

Risk: none; nothing installs it automatically.

Verification: the file is byte-for-byte the live drop-in
(ssh desktop cat ...); 40-secrets-encryption.yaml in the repository
already matches the host.
2026-11-12 01:38:58 +09:00
DongHyeonka 012452cf78 feat(observability): alert on host backups, drift and k3s serving certs
Backups, the daily drift check and the k3s serving certificates have no
alert. k3s renews certificates only when it starts within 120 days of
expiry, and the two kube-prometheus-stack kubelet certificate alerts
can never fire because the k3s kubelet exports no
kubelet_certificate_manager_* metric.

Add a PrometheusRule (platform-host-checks) for backup age, failed
runs, missing metrics, drift left for 6h, a stale drift check, and
serving certificate expiry (warning under 100 days, critical under 14).
Add the two remaining host timers (certificate expiry via openssl on
6443 and 10250; the drift check against origin/main) and an installer
that copies the scripts to a root-owned path, creates the textfile and
work directories and enables all four timers. Disable the two dead
kubelet certificate rules in kube-prometheus-stack.

Risk: the metrics need the node-exporter textfile collector, a one-line
change in W1's node-exporter values that was asked of W1. Until then
PlatformHostBackupMetricsAbsent fires after a day, which is the point.

Verification (desktop):
- test-platform-host-checks-alerts.sh: promtool check and unit tests
  pass; with the k3s threshold changed from 2 to 5 days they fail.
- render-observability-core.sh passes; the render has no Kubelet*
  certificate alerts and still has both KubeClientCertificateExpiration.
- k3s-cert-expiry.sh as the desktop user reads both certificates.
- install-host-checks.sh --check: systemd-analyze verify is clean.
2026-11-12 01:13:02 +09:00
DongHyeonka 77daa39a41 feat(backup): back up the k3s datastore and Gitea to AIStor
Nothing backs up the k3s datastore or Gitea's repositories, packages and
app.ini. W1 covers platform-postgres only. One SSD failure loses the
source, CI artefacts, published libraries and every cluster Secret.

Add two root systemd timers that write to a new AIStor bucket on the
HDD (platform-host-backups, same AIStor as W1's postgres backups):
- k3s datastore, daily: sqlite3 .backup of the live state.db plus the
  server token (k3s backup/restore docs: the token is needed to read
  it back), integrity_check, tar.gz, sha256, upload. Off-host copy is
  prepared behind two variables (gpg recipient file, rclone target) and
  stays off until the owner chooses a place.
- Gitea, weekly: gitea dump --skip-db streamed from the live container,
  listing checked for app.ini and repositories, sha256, upload. The DB
  is in the CNPG backup.
Each run writes textfile metrics for the alerts in the next commit.
create-host-backup-credentials.sh makes the bucket (50GiB quota,
lifecycle 56 days for gitea/, 30 days for k3s-datastore/), a
bucket-scoped policy and user, and a root-only env file; no key is
printed and mc gets keys only through a 0600 env file.

Rejected: in-cluster CronJobs. The datastore is a root-owned host file
and the dump needs the Gitea DB connection; a hostPath root pod or a
second Gitea-labelled pod is a larger privilege than a root timer.

Risk: not installed here (owner sudo steps). The k3s archive holds the
token; together with the datastore it decrypts every Secret. It lives
in a bucket only the backup user can read.

Verification (desktop): a dump streamed with --file - is a valid
tar.gz with app.ini; repositories appear as repos/<owner>/<name>.git
(29, matching the live count). The scripts parse with bash -n.
2026-11-12 01:13:02 +09:00
DongHyeonka e88725aab8 feat(host): add the k3s kubelet, audit and pod security drop-ins
The kubelet has no memory eviction threshold and no reservations, so
under memory pressure the kernel OOM killer picks a victim and
Postgres (oom_score_adj 985) is near the front. The API server writes
no audit log. Namespaces without labels have no Pod Security level, and
graceful node shutdown is off.

Add the files for one k3s restart: a kubelet drop-in (system 1 CPU/2Gi,
kube 0.5 CPU/1Gi, hard eviction memory 500Mi plus the two k3s disk
defaults, soft eviction 1Gi for 1m, shutdown 60s/20s), an API server
drop-in that appends the audit and admission-config flags, a Metadata
audit policy and a cluster Pod Security default (baseline, warn and
audit restricted, kube-system exempt).

Rejected: protect-kernel-defaults, recommended in review 7.3. CIS
dropped it in v1.7, and the sysctls it requires include
kernel.panic_on_oops=1, which reboots this dual-boot desktop on any
kernel oops; a reboot started the 2026-11-11 clock incident. The README
records the reason.

Risk: nothing is installed by this commit. The kubelet merges the
drop-in after k3s's 00-k3s-defaults.conf (k3s passes only --config-dir);
evictionHard lists all three keys because setting the map zeroes the
others.

Verification: the apply script's --check parses every file and asserts
the invariants (next commit).
2026-11-12 00:49:58 +09:00