From d1c7412f0781e7dc0f8aeb2db23d5befa2529aa2 Mon Sep 17 00:00:00 2001 From: kasun Date: Wed, 2 Dec 2026 04:29:17 +0100 Subject: [PATCH] docs: add OpenBao backup setup to runbooks --- docs/runbooks/openbao.md | 86 +++++++++++++++++++++++++++++++-- docs/runbooks/truenas-rustfs.md | 65 ++++++++++++++++++++++++- 2 files changed, 146 insertions(+), 5 deletions(-) diff --git a/docs/runbooks/openbao.md b/docs/runbooks/openbao.md index ef0f25b..776aae8 100644 --- a/docs/runbooks/openbao.md +++ b/docs/runbooks/openbao.md @@ -146,9 +146,89 @@ Only do this once steps 5 and 6 have worked. Check that Bitwarden has the admin 3. Check that you can still log in to the UI as `admin`. Then delete the root token from Bitwarden, but **keep the unseal key**. -## Set up backup storage +## Automatic backups -After first setup, [install RustFS on TrueNAS](truenas-rustfs.md). The runbook covers TrueNAS, Cloudflare, pfSense and RustFS. **This doesn't turn on automatic backups yet**, so keep [saving snapshots manually](#save-a-snapshot). +A CronJob from the OpenBao Helm chart saves a Raft snapshot every hour and uploads it to the `openbao-backups` bucket in RustFS on TrueNAS. Object lock keeps each backup for 30 days. The job logs in with Kubernetes auth and can only read snapshots. Its RustFS key can only upload. + +> Missed or failed backups don't trigger alerts yet. Check the job now and then, and still [save a snapshot](#save-a-snapshot) before upgrades. + +### Set up backups + +Do these in order. Otherwise, the hourly job fails until its login exists. + +1. Set up RustFS, then create the bucket and upload-only user. Follow [the RustFS runbook](truenas-rustfs.md), including step 8. +2. Add the backup user's key to the stack's config. Run these from the repo root, and paste each value when prompted: + + ```bash + pulumi config set --secret --cwd 06-openbao snapshotS3AccessKeyId + pulumi config set --secret --cwd 06-openbao snapshotS3SecretAccessKey + ``` + + Commit and push the change in the private config repo, because CI uses the pushed version. + +3. Set [`$POD`](#rules) and log in as `admin`. Run the login **by itself**, not pasted with the next steps, or the password prompt may not work. Then check it: + + ```bash + kubectl -n openbao exec -it "$POD" -- bao login -no-print -method=userpass username=admin + kubectl -n openbao exec "$POD" -- bao read -field=policies auth/token/lookup-self + ``` + + **Checkpoint:** it prints `[admin default]`. If it doesn't, stop. The next steps fail with `permission denied` without a valid login. + +4. Turn on Kubernetes logins. OpenBao uses its own service account and the cluster's CA to check logins: + + ```bash + kubectl -n openbao exec "$POD" -- bao auth enable kubernetes + kubectl -n openbao exec "$POD" -- bao write auth/kubernetes/config kubernetes_host=https://kubernetes.default.svc:443 + ``` + +5. Create the backup policy and role. The role only accepts the `openbao-snapshot` service account in the `openbao` namespace: + + ```bash + kubectl -n openbao exec -i "$POD" -- bao policy write openbao-snapshot - <<'EOF' + path "sys/storage/raft/snapshot" { + capabilities = ["read"] + } + EOF + kubectl -n openbao exec "$POD" -- bao write auth/kubernetes/role/openbao-snapshot bound_service_account_names=openbao-snapshot bound_service_account_namespaces=openbao token_policies=openbao-snapshot token_ttl=10m token_max_ttl=10m + ``` + +6. Remove the saved login: + + ```bash + kubectl -n openbao exec "$POD" -- bao token revoke -self + kubectl -n openbao exec "$POD" -- rm -f /home/openbao/.vault-token + ``` + +7. Deploy `06-openbao`. Then start a backup without waiting for the hourly run: + + ```bash + kubectl -n openbao create job --from=cronjob/openbao-snapshot openbao-snapshot-manual + kubectl -n openbao wait --for=condition=complete job/openbao-snapshot-manual --timeout=5m + kubectl -n openbao logs job/openbao-snapshot-manual + ``` + + **Checkpoint:** the job completes, and the log ends with an `upload:` line for a `bao_-