Skip to content

Keep a secret

Keep a secret in a vault of the installation: each value is encrypted on your machine before it leaves it, and no command prints it back.

Before you start

  • A cluster from Prepare the cluster with --profile internal-developer-platform: it brings the secrets reef, the Nereid openbao and the vault default.
  • The values in environment variables or files, never on the command line, where the shell history keeps them.

Steps

1. Create a secret from environment variables

nereus secrets create encrypts each value with the key of the vault's Mandate, then stores it.

nereus secrets create google-oauth \
  --from-env GOOGLE_CLIENT_ID \
  --from-env GOOGLE_CLIENT_SECRET
output
✓ secrets/vaults/default/secrets/google-oauth created (key SHA256:GQ8TrJ9h6ZrNYHItBycWK+tXkURjowfJWcjEyabRIKI)
Stored encrypted; a Kubernetes Secret is made only when a binding asks for it (#532).

2. Take a key from a file

--from-file KEY=PATH takes the file's bytes, for a private key or a certificate.

nereus secrets create github-app \
  --from-file private-key=key.pem \
  --from-env APP_ID
output
✓ secrets/vaults/default/secrets/github-app created (key SHA256:GQ8TrJ9h6ZrNYHItBycWK+tXkURjowfJWcjEyabRIKI)
Stored encrypted; a Kubernetes Secret is made only when a binding asks for it (#532).

3. Change it from a file

create refuses a secret that exists. Write the encrypted secret to a file, safe to keep, then nereus secrets apply it; each change is a new version.

nereus secrets create google-oauth \
  --from-env GOOGLE_CLIENT_ID \
  --from-env GOOGLE_CLIENT_SECRET \
  --dry-run --output yaml > google-oauth.yaml
nereus secrets apply --from-file google-oauth.yaml
output
✓ secrets/vaults/default/secrets/google-oauth configured

Check it worked

nereus secrets list shows the keys' names, never a value.

nereus secrets list
output
VAULT    NAME          KEYS                  STATUS  AGE
default  github-app    APP_ID, +1            Ready   9s
default  google-oauth  GOOGLE_CLIENT_ID, +1  Ready   10s

Clean up

Deleted for good

Deleting a secret destroys every version of it in OpenBao.

nereus secrets delete default/google-oauth
nereus secrets delete github-app
output
✓ secrets/vaults/default/secrets/google-oauth deleted
✓ secrets/vaults/default/secrets/github-app deleted

Next

Learn more