Namespaces
Namespaces let you store multiple values for the same secret key — one per environment — within the same vault.
The Problem
When working across multiple environments, you often need the same secret name to hold different values:
DATABASE_PASSWORDfor staging points to one databaseDATABASE_PASSWORDfor production points to another
Without namespaces, you'd need to manually swap values or maintain separate vaults.
How Namespaces Work
A namespace is a prefix on the vault key, separated by a colon:
staging:DATABASE_PASSWORD
production:DATABASE_PASSWORDBoth are stored in the same vault, independently. You load one at a time.
Storing Namespaced Secrets
kredenv set DATABASE_PASSWORD -n staging
kredenv set DATABASE_PASSWORD -n productionOr using the colon syntax directly:
kredenv set staging:DATABASE_PASSWORD
kredenv set production:DATABASE_PASSWORDDeclaring in kredsfile.yaml
secrets:
- key: DATABASE_PASSWORD
namespace: staging
- key: DATABASE_PASSWORD
namespace: production
- key: API_KEY
namespace: staging
- key: API_KEY
namespace: productionLoading a Namespace
Via autoload_namespace — set a default namespace in your kredsfile:
autoload: true
autoload_namespace: stagingkredenv will inject all staging:* secrets automatically on cd.
Via exec — inject a specific namespace for a single command:
kredenv exec -n staging -- terraform plan
kredenv exec -n production -- terraform applyVia load — manually load a namespace into your shell:
kredenv load -n stagingListing Namespaced Secrets
# list secrets declared in kredsfile.yaml for staging namespace
kredenv list -n staging
# list all secrets in the vault across all namespaces
kredenv list --allFlat and Namespaced Together
You can mix flat and namespaced secrets in the same kredsfile:
secrets:
- key: GLOBAL_API_KEY # flat, always loaded
- key: DATABASE_PASSWORD
namespace: staging # only loaded when namespace is staging
- key: DATABASE_PASSWORD
namespace: production # only loaded when namespace is productionWhen autoload_namespace is empty, only flat secrets are autoloaded. Namespaced secrets require an explicit namespace to be set.