Feature: Deploy OpenBao as an HA secrets manager on k3s #65

Open
opened 2026-11-28 17:37:18 +01:00 by claude-bot · 1 comment

Goal

Run OpenBao on k3s as the central secrets manager for machine secrets: Docker stacks deployed by homelab-ansible first, k3s workloads later. Human passwords stay in Bitwarden.

OpenBao is chosen over HashiCorp Vault because it is open source (MPL-2.0) and API-compatible with Vault.

Out of scope (follow-up issues)

  • External Secrets Operator for k3s workloads
  • Switching homelab-ansible from ansible-vault to OpenBao lookups
  • Moving existing secrets into OpenBao

Decisions before coding

  • Stack: add it to 03-k8s-infra next to cert-manager and Longhorn, or give it its own stack. 03 deploys on merge to main, so pulumi up must only create resources. Init and unseal stay manual (see below).
  • Unseal strategy: decide before init, because changing it later needs a seal migration.
    • Manual Shamir (e.g. 5 shares, threshold 3): simplest, but all 3 pods need unsealing after every restart.
    • Auto-unseal: check which seal types the chosen OpenBao version supports (e.g. transit, static key, PKCS#11). The unseal key must not live in the same cluster without protection.
  • Backup target: off-cluster object storage, e.g. MinIO or Garage on TrueNAS, with versioning and object lock (WORM) so a compromised cluster can't delete or overwrite backups.
  • Hostname: e.g. bao.<domain> through Traefik with the letsencrypt-prod ClusterIssuer, like the Longhorn UI.

Implementation (Pulumi)

Placement

  • Namespace openbao.
  • Schedule on workers only: the masters are tainted, so no tolerations are needed.
  • One pod per physical Proxmox host. Check that k3s-worker-1..3 run on different hosts, then use required pod anti-affinity on kubernetes.io/hostname. Optionally, let k8s-bootstrap add topology.kubernetes.io/zone=<pve-host> labels and spread on those.
  • PodDisruptionBudget maxUnavailable: 1 (the chart has one).

Helm release openbao/openbao (k8s.helm.v3.Release, same pattern as the existing releases)

  • server.ha.enabled: true, server.ha.replicas: 3
  • server.ha.raft.enabled: true, with retry_join entries for all 3 pods
  • dataStorage on k3s's built-in local-path StorageClass, small (e.g. 2Gi). Raft replicates between the pods, so each pod keeps a full copy on its own node's disk. No Longhorn (that would replicate twice: 9 copies) and no truenas-nfs (Raft needs low-latency local disk).
  • Audit log to stdout instead of an auditStorage volume. local-path lives on the root disk, which must stay clear of DiskPressure.
  • TLS between the pods and for Raft: a cert-manager Certificate (internal issuer) mounted into the pods
  • UI enabled. Ingress through Traefik with letsencrypt-prod
  • Resource requests/limits
  • Telemetry enabled, with a Prometheus scrape config for 05-monitoring

Network

  • NetworkPolicy: allow API 8200 from Traefik and from namespaces that need it. Allow Raft 8201 only between OpenBao pods.

Pulumi config and secrets

  • New values via config.requireSecret() (e.g. hostname parts if they are not taken from domain).
  • After changing local config, commit and push it to main in the private config repo before opening or updating a PR that needs it.
  • No unseal keys, root token or internal IPs in code, config or CI logs.

Manual steps on the live cluster (once, never in CI)

  1. Deploy (merge). The pods start sealed and not initialised. That's expected.
  2. bao operator init on openbao-0. Store the unseal/recovery keys and the initial root token in Bitwarden as separate items.
  3. Unseal openbao-0, then openbao-1 and openbao-2 (they join through retry_join).
  4. Check bao operator raft list-peers shows 3 voters and bao status shows HA mode with 1 active node.

Initial configuration (as code later, e.g. a script or a separate Pulumi stack with the Vault/OpenBao provider)

  • Audit device enabled, writing to stdout.
  • KV v2 engine at secret/. Layout: secret/stacks/<service>/... for Docker stacks, secret/k8s/<namespace>/... for later.
  • Policy ansible-stacks: read-only on secret/data/stacks/*.
  • AppRole ansible-runner with that policy and a short token TTL. Store its role_id/secret_id in /etc/homelab-ansible/ on the ansible LXC.
  • Kubernetes auth method enabled (ready for ESO).
  • Personal admin login (userpass, or OIDC via Gitea), then revoke the root token.

Backups

Raft replication isn't a backup: a deleted or corrupted secret is replicated too. Open-source OpenBao has no built-in snapshot scheduler (that's a Vault Enterprise feature), so the standard is a scheduled job calling the snapshot API. Snapshots of the PVCs (e.g. Velero) aren't used, because the snapshot API is what gives a consistent copy.

  • Kubernetes CronJob (e.g. hourly or every 6 hours) runs bao operator raft snapshot save. It is part of the Pulumi code, not set up by hand.
  • The job logs in with Kubernetes auth: a dedicated service account and policy allowing only read on sys/storage/raft/snapshot. No long-lived token.
  • Upload to the off-cluster object storage chosen above, with versioning and object lock. Retention is set by a lifecycle rule on the bucket (e.g. hourly for 2 days, daily for 30 days).
  • Snapshots are already encrypted by OpenBao's barrier. Restoring needs the unseal/recovery keys, so keep them in Bitwarden, separate from the backups.
  • The job pushes a "last successful backup" metric (e.g. to Pushgateway), or the bucket is checked for a recent object.
  • Restore test: restore the latest snapshot into a throwaway single-node OpenBao (e.g. in a temporary namespace) and read a known test secret. Do this manually once and document it; automate it as a scheduled job later.

Monitoring (05-monitoring)

  • Scrape OpenBao metrics.
  • Alerts: a pod is sealed, no active leader, Raft peer missing, no successful backup in the last 2 intervals.

Docs

  • docs/runbooks/openbao.md: init, unseal after a reboot, replace a dead Raft peer (bao operator raft remove-peer, delete the pod's PVC so it rejoins empty and copies the data from the others), restore a snapshot, rotate the AppRole secret_id, break-glass access.
  • Notes in the stack's CLAUDE.md (why local-path and not Longhorn, why init is manual).

Acceptance criteria

  • 3 OpenBao pods, one per physical Proxmox host: 1 active, 2 standby.
  • Deleting the active pod fails over to a standby. The API stays reachable through the ingress.
  • Rebooting one Proxmox host keeps OpenBao serving. The returning pod rejoins after unseal.
  • The ansible LXC can read a test secret under secret/stacks/ with the AppRole, and nothing else.
  • Root token revoked. Unseal/recovery keys and break-glass secrets are in Bitwarden.
  • Snapshots land in the off-cluster bucket on schedule, and a missed backup raises an alert.
  • Snapshot restore into a throwaway instance tested and documented.
  • npm run typecheck and pulumi preview pass for the changed stack.
## Goal Run OpenBao on k3s as the central secrets manager for machine secrets: Docker stacks deployed by `homelab-ansible` first, k3s workloads later. Human passwords stay in Bitwarden. OpenBao is chosen over HashiCorp Vault because it is open source (MPL-2.0) and API-compatible with Vault. ## Out of scope (follow-up issues) - External Secrets Operator for k3s workloads - Switching `homelab-ansible` from ansible-vault to OpenBao lookups - Moving existing secrets into OpenBao ## Decisions before coding - [x] **Stack**: add it to `03-k8s-infra` next to cert-manager and Longhorn, or give it its own stack. `03` deploys on merge to `main`, so `pulumi up` must only create resources. Init and unseal stay manual (see below). - [x] **Unseal strategy**: decide before `init`, because changing it later needs a seal migration. - Manual Shamir (e.g. 5 shares, threshold 3): simplest, but all 3 pods need unsealing after every restart. - Auto-unseal: check which seal types the chosen OpenBao version supports (e.g. transit, static key, PKCS#11). The unseal key must not live in the same cluster without protection. - [ ] **Backup target**: off-cluster object storage, e.g. MinIO or Garage on TrueNAS, with versioning and object lock (WORM) so a compromised cluster can't delete or overwrite backups. - [x] **Hostname**: e.g. `bao.<domain>` through Traefik with the `letsencrypt-prod` ClusterIssuer, like the Longhorn UI. ## Implementation (Pulumi) ### Placement - [x] Namespace `openbao`. - [x] Schedule on workers only: the masters are tainted, so no tolerations are needed. - [x] One pod per physical Proxmox host. Check that `k3s-worker-1..3` run on different hosts, then use required pod anti-affinity on `kubernetes.io/hostname`. Optionally, let `k8s-bootstrap` add `topology.kubernetes.io/zone=<pve-host>` labels and spread on those. - [x] PodDisruptionBudget `maxUnavailable: 1` (the chart has one). ### Helm release `openbao/openbao` (`k8s.helm.v3.Release`, same pattern as the existing releases) - [x] `server.ha.enabled: true`, `server.ha.replicas: 3` - [x] `server.ha.raft.enabled: true`, with `retry_join` entries for all 3 pods - [x] `dataStorage` on k3s's built-in `local-path` StorageClass, small (e.g. 2Gi). Raft replicates between the pods, so each pod keeps a full copy on its own node's disk. No Longhorn (that would replicate twice: 9 copies) and no `truenas-nfs` (Raft needs low-latency local disk). - [x] Audit log to stdout instead of an `auditStorage` volume. `local-path` lives on the root disk, which must stay clear of `DiskPressure`. - [x] TLS between the pods and for Raft: a cert-manager `Certificate` (internal issuer) mounted into the pods - [x] UI enabled. Ingress through Traefik with `letsencrypt-prod` - [x] Resource requests/limits - [ ] Telemetry enabled, with a Prometheus scrape config for `05-monitoring` ### Network - [x] NetworkPolicy: allow API `8200` from Traefik and from namespaces that need it. Allow Raft `8201` only between OpenBao pods. ### Pulumi config and secrets - [ ] New values via `config.requireSecret()` (e.g. hostname parts if they are not taken from `domain`). - [ ] After changing local config, commit and push it to `main` in the private config repo before opening or updating a PR that needs it. - [ ] No unseal keys, root token or internal IPs in code, config or CI logs. ## Manual steps on the live cluster (once, never in CI) 1. Deploy (merge). The pods start sealed and not initialised. That's expected. 2. `bao operator init` on `openbao-0`. Store the unseal/recovery keys and the initial root token in Bitwarden as separate items. 3. Unseal `openbao-0`, then `openbao-1` and `openbao-2` (they join through `retry_join`). 4. Check `bao operator raft list-peers` shows 3 voters and `bao status` shows HA mode with 1 active node. ## Initial configuration (as code later, e.g. a script or a separate Pulumi stack with the Vault/OpenBao provider) - [x] Audit device enabled, writing to stdout. - [ ] KV v2 engine at `secret/`. Layout: `secret/stacks/<service>/...` for Docker stacks, `secret/k8s/<namespace>/...` for later. - [ ] Policy `ansible-stacks`: read-only on `secret/data/stacks/*`. - [ ] AppRole `ansible-runner` with that policy and a short token TTL. Store its role_id/secret_id in `/etc/homelab-ansible/` on the `ansible` LXC. - [ ] Kubernetes auth method enabled (ready for ESO). - [ ] Personal admin login (userpass, or OIDC via Gitea), then revoke the root token. ## Backups Raft replication isn't a backup: a deleted or corrupted secret is replicated too. Open-source OpenBao has no built-in snapshot scheduler (that's a Vault Enterprise feature), so the standard is a scheduled job calling the snapshot API. Snapshots of the PVCs (e.g. Velero) aren't used, because the snapshot API is what gives a consistent copy. - [ ] Kubernetes CronJob (e.g. hourly or every 6 hours) runs `bao operator raft snapshot save`. It is part of the Pulumi code, not set up by hand. - [ ] The job logs in with Kubernetes auth: a dedicated service account and policy allowing only `read` on `sys/storage/raft/snapshot`. No long-lived token. - [ ] Upload to the off-cluster object storage chosen above, with versioning and object lock. Retention is set by a lifecycle rule on the bucket (e.g. hourly for 2 days, daily for 30 days). - [ ] Snapshots are already encrypted by OpenBao's barrier. Restoring needs the unseal/recovery keys, so keep them in Bitwarden, separate from the backups. - [ ] The job pushes a "last successful backup" metric (e.g. to Pushgateway), or the bucket is checked for a recent object. - [ ] Restore test: restore the latest snapshot into a throwaway single-node OpenBao (e.g. in a temporary namespace) and read a known test secret. Do this manually once and document it; automate it as a scheduled job later. ## Monitoring (`05-monitoring`) - [ ] Scrape OpenBao metrics. - [ ] Alerts: a pod is sealed, no active leader, Raft peer missing, no successful backup in the last 2 intervals. ## Docs - [ ] `docs/runbooks/openbao.md`: init, unseal after a reboot, replace a dead Raft peer (`bao operator raft remove-peer`, delete the pod's PVC so it rejoins empty and copies the data from the others), restore a snapshot, rotate the AppRole secret_id, break-glass access. - [ ] Notes in the stack's `CLAUDE.md` (why `local-path` and not Longhorn, why init is manual). ## Acceptance criteria - [x] 3 OpenBao pods, one per physical Proxmox host: 1 active, 2 standby. - [ ] Deleting the active pod fails over to a standby. The API stays reachable through the ingress. - [ ] Rebooting one Proxmox host keeps OpenBao serving. The returning pod rejoins after unseal. - [ ] The `ansible` LXC can read a test secret under `secret/stacks/` with the AppRole, and nothing else. - [ ] Root token revoked. Unseal/recovery keys and break-glass secrets are in Bitwarden. - [ ] Snapshots land in the off-cluster bucket on schedule, and a missed backup raises an alert. - [ ] Snapshot restore into a throwaway instance tested and documented. - [x] `npm run typecheck` and `pulumi preview` pass for the changed stack.
kasun added reference feature/deploy-openbao-ha 2026-11-30 03:26:26 +01:00
kasun added a new dependency 2026-12-01 02:28:39 +01:00

Kubernetes Secrets are now encrypted in etcd on the live cluster with secretbox (#76, done on 2026-12-01). A new test Secret and an existing Secret were checked directly in etcd, and both were encrypted. Secret encryption no longer blocks OpenBao.

  • The matching 02-k8s-bootstrap change for fresh installs is tracked in #76.
  • This doesn't limit who can read Secrets through the Kubernetes API. After OpenBao is deployed, check who can read Secrets in the openbao namespace.
Kubernetes Secrets are now encrypted in etcd on the live cluster with `secretbox` (#76, done on 2026-12-01). A new test Secret and an existing Secret were checked directly in etcd, and both were encrypted. **Secret encryption no longer blocks OpenBao.** - The matching `02-k8s-bootstrap` change for fresh installs is tracked in #76. - This doesn't limit who can read Secrets through the Kubernetes API. After OpenBao is deployed, check who can read Secrets in the `openbao` namespace.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Depends on
Reference: kasun/homelab-infrastructure-as-code#65