Prompt
How do I manage secrets across local dev, GitHub Actions, and Kubernetes?
Latest observation
Oct 25, 2026
OpenAI APIWeb search: off
A good way to manage secrets across local dev, GitHub Actions, and Kubernetes is to use the same core principles everywhere:
- Keep secrets out of Git
- Use environment-specific secret stores
- Inject secrets at runtime, not build time
- Rotate and audit access
- Prefer short-lived credentials when possible
Recommended pattern
1) Local development
Use one of these:
.envfiles for local-only development- A secret manager CLI like:
- 1Password CLI
- Doppler
- Vault
- AWS SSM / Secrets Manager
- Keep
.envin.gitignore - Commit a
.env.examplewith placeholders only
Example:
DATABASE_URL=postgres://user:pass@localhost:5432/app
JWT_SECRET=change-me
For consistency, load them with your app or tooling:
- Node:
dotenv - Python:
python-dotenv - Docker Compose:
env_file
2) GitHub Actions
Use GitHub Secrets for CI/CD-only secrets:
- Repository secrets for one app
- Environment secrets for
dev,staging,prod - Organization secrets if shared across repos
Best practices:
- Use GitHub OIDC to get cloud credentials instead of storing long-lived cloud keys
- Keep secrets scoped to the smallest environment possible
- Never echo secrets in logs
- Avoid passing secrets as plain build args if they end up in image layers
Example:
jobs:
test:
runs-on: ubuntu-latest
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
steps:
- uses: actions/checkout@v4
- run: npm test
For cloud auth, prefer OIDC:
- GitHub Actions assumes a cloud role temporarily
- No static AWS/GCP/Azure keys stored in GitHub
3) Kubernetes
Do not hardcode secrets in manifests or images.
Options:
- Native Kubernetes Secrets: simple, but base64-encoded only, not encrypted by default unless you enable encryption at rest
- External Secrets Operator: sync secrets from AWS Secrets Manager, Azure Key Vault, GCP Secret Manager, Vault, etc.
- Secrets Store CSI Driver: mount secrets directly from external secret stores
- Vault Agent / Vault Injector: for HashiCorp Vault users
Recommended for most teams:
- Store secrets in a real secret manager
- Sync or mount them into Kubernetes at runtime
Example Kubernetes Secret:
apiVersion: v1
kind: Secret
metadata:
name: app-secrets
type: Opaque
stringData:
DATABASE_URL: postgres://user:pass@db:5432/app
Then reference it:
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: app-secrets
key: DATABASE_URL
Best overall architecture
A common, clean setup is:
- Local dev:
.envor 1Password/Doppler - GitHub Actions: GitHub Secrets + OIDC for cloud access
- Kubernetes: external secret manager + External Secrets Operator
This gives you:
- one source of truth per environment
- no secrets in source control
- less duplication
- easier rotation
Important tips
Avoid these mistakes
- Committing
.envfiles - Baking secrets into Docker images
- Using the same secret across dev/staging/prod
- Storing long-lived cloud keys in GitHub if OIDC is available
- Relying on plain Kubernetes Secrets without encryption/auditing for sensitive prod use
Rotate secrets
Have a rotation process for:
- DB passwords
- API keys
- signing keys
- cloud credentials
Use different secrets per environment
Example:
devuses a dev database and API keysstaginguses staging credentialsproduses production credentials
Control access tightly
- Least privilege
- Separate IAM roles/service accounts per environment
- Restrict who can read secrets in GitHub/Kubernetes/cloud consoles
Simple practical setup
If you want a pragmatic stack that works well:
- Local:
.env+.env.example - CI: GitHub Secrets + OIDC to cloud
- Kubernetes: External Secrets Operator + AWS Secrets Manager / GCP Secret Manager / Azure Key Vault
- Optional: SOPS or Sealed Secrets if you want GitOps-managed encrypted secret manifests
If you want, I can also give you:
- a concrete example setup for AWS/GCP/Azure, or
- a sample repo layout + YAML files for all three environments.