Use a secret in a namespace¶
Give a namespace a Kubernetes Secret made from a secret of the installation, under the key names its app expects: a binding asks for it, and the vault says which namespaces may.
Before you start¶
- A secret
google-oauthin the vaultdefault, from Keep a secret. - The namespace
identity, such as fromkubectl create namespace identity.
Steps¶
1. Allow the namespace¶
A vault lists the namespaces that may bind its secrets in spec.allowedNamespaces. Write the vault as a file with nereus secrets vault get, add identity there, then apply the file.
nereus secrets vault get default \
--output yaml > default.yaml
nereus secrets vault apply \
--from-file default.yaml
✓ secrets/vaults/default configured
2. Bind the secret¶
nereus secrets binding create makes the Kubernetes Secret in the namespace from the secret's current version; each --key NAME=KEY renames a key, and without any, every key keeps its own name. A namespace the vault does not allow, or a key the secret lacks, is refused before anything is written.
nereus secrets binding create keycloak-google \
--secret default/google-oauth \
--namespace identity \
--key client-id=GOOGLE_CLIENT_ID \
--key client-secret=GOOGLE_CLIENT_SECRET
✓ secrets/vaults/default/secrets/google-oauth/secretbindings/identity/keycloak-google created
Secret keycloak-google ready in namespace identity.
Next steps:
nereus secrets binding get keycloak-google --namespace identity
A chart asks the same way, with a SecretBinding among its templates, as test/charts/binding-demo does; helm uninstall removes it and its Kubernetes Secret. A release asks with --secret.
Check it worked¶
nereus secrets binding list shows each binding with FOR, who asked: a release, a chart from its Helm labels, or the CLI user.
nereus secrets binding list
NAME SECRET NAMESPACE FOR STATUS AGE
keycloak-google default/google-oauth identity system:admin Ready 12s
binding-demo default/google-oauth tools chart binding-demo Ready 4s
A secret is not deleted while bindings use it: nereus secrets get lists them.
Clean up¶
nereus secrets binding delete deletes the Kubernetes Secret first, then the binding.
nereus secrets binding delete keycloak-google \
--namespace identity
✓ secrets/vaults/default/secrets/google-oauth/secretbindings/identity/keycloak-google deleted
Next steps:
nereus secrets binding list --namespace identity
Next¶
- Release a chart that reads the secret through a binding.
- Give a team a vault of its own with
nereus secrets vault create --allow-namespace.
Learn more¶
- The secrets reef: vaults, secrets and bindings, every command.