Enhancement: Encrypt Kubernetes Secrets at rest in k3s #76
Notifications
Due Date
No due date set.
Blocks
#65 Feature: Deploy OpenBao as an HA secrets manager on k3s
kasun/homelab-infrastructure-as-code
Reference: kasun/homelab-infrastructure-as-code#76
Reference in new issue
Block a user
Goal
Encrypt all Kubernetes Secrets in etcd with
secretboxbefore merging the OpenBao branch (#65). Merging it deploys OpenBao, and cert-manager then stores its private keys as Secrets.Branch:
enhancement/enable-secrets-encryptionWhat's affected
k3s encrypts Secrets for the whole cluster, so the app stacks don't need changes. Checked on 2026-12-01, using names only:
Not covered: data in volumes, Secrets mounted in pods, root access to a master, or anyone allowed to read Secrets. The encryption key is stored on the masters, so full VM backups can include it. Volume encryption and access permissions need separate tickets.
How it's done
02-k8s-bootstrap.02only runs the k3s installer on a fresh install and ignores later changes to those commands. Adding the flags also doesn't encrypt existing Secrets. Both setups must use the same settings.1. Update Pulumi and write the runbook
02-k8s-bootstrap/index.ts, add--secrets-encryptionand--secrets-encryption-provider=secretboxto all 3 master installs. Workers don't need them. Keep the rule that ignores changes to existing commands.npm run typecheckandpulumi preview. The preview must show no changes to existing install commands. Include both outputs in the PR.docs/runbooks/k3s-secrets-encryption.mdwith the exact steps for the live change and checks. Mentionsecretboxin the cluster rebuild runbook.Don't deploy
02or use--target-replacefor this change. Merge the PR after the live change has been checked, so a replacement master doesn't join with different settings.2. Turn on encryption in the running cluster
Follow the runbook, with deployments paused. First check that all nodes are
Ready, etcd is healthy and each master can be reached directly over SSH. Use the same first master throughout. Restart one master at a time, starting with that one. Wait until it'sReadyand etcd is healthy before restarting the next.secretboxin a separate k3s config file. Don't change the existing config. First check that the new file doesn't already exist and that k3s doesn't use a custom config path.start, with matching hashes. Check that both settings are active on all 3 masters, because key rotation uses the server's setting to choose the encryption type.secretboxkey and re-encrypts existing Secrets. Wait forreencrypt_finished.reencrypt_finished, the hashes match and the active key isXSalsa20-POLY1305.If a check fails, stop. Don't repeat key rotation, force re-encryption or delete k3s files. Never interrupt key rotation, and don't restart any masters until it finishes. A crash during this step could stop the cluster from starting (k3s issue 13763), and we haven't confirmed a fix.
Using
secretboxfrom the start is based on thev1.36.2+k3s1server code. It hasn't been tested, and the k3s guide for existing clusters doesn't cover it.3. Check that it worked
k8s:enc:secretbox:v1:. Only show this prefix, then delete the test Secret.Done when
secretbox.Don't put tokens, keys, Secret values or internal IPs in this issue, the repo or logs.
References