my-homelab-configs/apps/secrets-lab
juvenal.diaz dd99af4f58 Add secret and certificate lifecycle lab 2026-11-10 10:37:54 -06:00
..
README.md Add secret and certificate lifecycle lab 2026-11-10 10:37:54 -06:00
kustomization.yaml Add secret and certificate lifecycle lab 2026-11-10 10:37:54 -06:00
resources.yaml Add secret and certificate lifecycle lab 2026-11-10 10:37:54 -06:00
vault.yaml Add secret and certificate lifecycle lab 2026-11-10 10:37:54 -06:00

README.md

Secrets and certificate lifecycle lab

This opt-in lab uses External Secrets Operator (ESO) to copy a demo value from an in-memory Vault development server into a Kubernetes Secret. A separate cert-manager self-signed Issuer issues a short-lived demo certificate. Jeannie creates Argo CD applications for the controllers and the lab resources. Both controllers and their CRDs are cluster-wide, although the demo resources and Vault service are confined to the secrets-lab namespace. Existing controllers are not adopted automatically.

Vault dev mode uses an automatically generated root token in a Kubernetes Secret and HTTP inside the cluster. It has no durable storage; a Vault restart loses its contents. This setup is only for disposable values, not real passwords, production secrets, or a backup of your existing secrets. The demo certificate is self-signed and is not trusted by browsers. Neither Dex nor OCI edge certificates are changed.

Your SOPS workflow stores encrypted values in Git and decrypts them when needed. This lab instead stores the value in Vault, and ESO periodically synchronizes a Kubernetes Secret. The generated Kubernetes Secret still exists in the cluster; ESO does not eliminate the need to protect Kubernetes secrets, access, or backups. A real secret-manager deployment would need durable storage, access policies, TLS, token management, and recovery planning.

Run

Push the commit first; Argo CD reads the configured GitOps repository's main branch. On Debian, with the desired Jeannie profile selected:

cd ~/my-homelab-configs
git pull --ff-only gitea main
./jeannie secrets-lab plan
./jeannie secrets-lab apply
./jeannie secrets-lab test

The first apply downloads two charts and waits for their CRDs and the Vault deployment. Argo CD may need additional time to synchronize the demo resources. No secret values are printed. Check progress with ./jeannie secrets-lab status.

Exercises

# Write a new random demo value to Vault and verify ESO copied it.
./jeannie secrets-lab rotate

# If the disposable Vault restarted, create a replacement only if needed.
./jeannie secrets-lab recover

# Delete only the lab TLS Secret and verify cert-manager reissues it.
./jeannie secrets-lab recover-cert

Certificate reissuance is a recovery exercise. The Certificate also has a 24-hour duration and an eight-hour renewal window so you can inspect automatic renewal using kubectl describe certificate -n secrets-lab secrets-lab-demo with the selected cluster's kubeconfig. Removing the demo TLS Secret changes its private key; no other TLS Secret is touched. Vault recovery creates a new value if the in-memory database was lost; it cannot restore the old value.

The chart versions are pinned for the homelab's Kubernetes 1.31 compatibility. That Kubernetes release and these controller versions require an upgrade plan; do not treat this lab as a supported production secret-management deployment.