Documentation Index
Fetch the complete documentation index at: https://docs.emergence.ai/llms.txt
Use this file to discover all available pages before exploring further.
Manage Secrets
This page is about how a solution gets secrets at runtime. The platform handles sourcing, rotation, and delivery — your job is to declare what you need and read it correctly. For the platform-side architecture (Infisical vs ESO + GCP Secret Manager, rotation mechanics, Workload Identity), see Security › Secrets Management and Deployment › Infrastructure › Secrets.Secret pipeline
Read the diagram left-to-right: the upstream backend is the source of truth; ESO or Infisical syncs values into a K8s Secret in your namespace;em-service injects them into your pod as env vars (via envFrom) and/or files (via volume mount). On rotation, Reloader detects the K8s Secret change and rolls your Deployment.
Two delivery shapes
Theem-service chart delivers secrets to your pod in two ways. Pick whichever fits the consumer:
| Shape | Format | Best for |
|---|---|---|
| Environment variable | Loaded via envFrom from a synthesized <service>-secrets Kubernetes Secret | Most use cases (DB URLs, API keys, OIDC client secrets) |
| File mount | Files at /mnt/secrets/<key> | Multi-line secrets (PEM keys, certs); SDKs that expect a file path (gcloud, kubeconfig) |
Steps
Declare the secret in your chart
Reference the secret by For file-mount secrets, declare a volume and mount it (the platform’s
secretKeyRef in your values.yaml. The Kubernetes Secret itself (<service>-secrets) is created by the platform’s secret pipeline — you do not check secret values into the chart.charts/<solution>/values.yaml
em-service chart supports custom mounts via volumeMounts and volumes):Read at runtime
Environment variables: standard Two rules:
os.environ. File mounts: read from disk lazily.- Never log a secret value. Wrap reads in repr-safe types or use
pydantic.SecretStr. - Don’t re-read on every request. Read once at startup; re-read only when a rotation signal fires (see Stakater Reloader below).
Add a new secret
Adding a secret requires two changes:
See Security › Secrets Management and Deployment › Infrastructure › Secrets for backend setup.
- Add it to your chart (the
envVarssnippet above) referencing the key name. - Add the value to the upstream secret backend in each environment.
| Deployment | Where to add the secret |
|---|---|
| Local dev (docker-compose / Kind) | .env (gitignored) or kubectl create secret generic <solution>-secrets --from-literal=key=value |
| Self-hosted (Infisical) | Infisical UI for the project; ESO syncs to the cluster |
| Cloud (GCP Secret Manager via ESO) | gcloud secrets create + grant Workload Identity SA secretmanager.secretAccessor |
Local development
For local-dev secrets:
- Use
.env(in.gitignore) for env vars;set -a; source .env; set +abeforeuv run. - Mount fixture files for file-style secrets via docker-compose
volumes. - Never commit secrets — even fixture/dummy ones if they look real. Use values like
dev-only-not-a-real-key. - Generate fresh keys for tests (e.g., the
dev-private.pemfrom Authenticate Users).
Where the values come from
Solutions don’t talk to the secret backend directly — the platform’s secret pipeline (ESO for cloud, Infisical for self-hosted) materializes upstream secrets into Kubernetes Secrets in your namespace. Your chart’ssecretKeyRef references those K8s Secrets. The platform handles:
- Authentication to the upstream backend (Workload Identity in GCP, machine identities in Infisical)
- Sync intervals (ESO defaults to 1h; configurable per ExternalSecret)
- Resync on upstream change
Rotation
The platform pairs secrets with Stakater Reloader. When the underlying K8s Secret changes (because ESO synced an update from upstream), Reloader rolls your Deployment automatically — if you opt in by annotating the Deployment.em-service adds the annotation by default for the secrets it injects via envFrom. For custom volume mounts (like <solution>-tls), add the annotation manually:
charts/<solution>/values.yaml
Verification
secret <name> not found: ESO/Infisical hasn’t synced yet, or the upstream secret doesn’t exist. See Troubleshooting › secrets.
Next steps
em-service env model
Reference for
env vs envVars precedence and dedup rules.Use shared storage
Storage credentials follow the same pattern as DB creds.
Secrets management
Platform-side architecture (ESO vs Infisical).
Troubleshooting › secrets
Pod CrashLoopBackOff with “secret not found” and similar.

