Similar to ConfigMaps, you can inject secrets into your application.
1. Single Key/Value from Secret
Use valueFrom.secretKeyRef to pull a specific key. The name follows the <applicationName>-<nameSuffix> pattern.
2. Bulk Environment Variables from Secret (envFrom)
To load all keys from a Secret as environment variables, use the envFrom block:
- Managed Secret: Use
nameSuffix to target the Secret created by this chart. - External Secret: Use
name to reference an existing Secret.
Note: The first key in the envFrom block (e.g., database-credentials) is a unique identifier for that object within the block and should be descriptive.
# Scenario: applicationName is 'my-application'
# 1. Single key from managed Secret
env:
KEY:
valueFrom:
secretKeyRef:
name: my-application-db-credentials
key: USER
# 2. All keys from managed Secret
envFrom:
database-credentials:
type: secret
nameSuffix: db-credentials
# 3. All keys from an existing external Secret
envFrom:
external-secret:
type: secret
name: my-existing-secret