.env · generator · Kubernetes

Kubernetes .env Generator

Kubernetes separates config into two primitives: ConfigMaps (non-sensitive) and Secrets (sensitive). This generator produces a .env you can feed directly into kubectl create secret generic --from-env-file or split into a ConfigMap.

.env for Kubernetes · 7 keys
Customize →
APP_NAMESPACE=default
APP_REPLICAS=2
DATABASE_URL=postgres://...svc.cluster.local/app
REDIS_URL=redis://redis.default.svc.cluster.local:6379
JWT_SECRET=iOJTpWfA_9GbyyBGf--w2NaJSZavjnHoyJJeR0Dc-dRKqPIc
LOG_LEVEL=info
METRICS_PORT=9090

Secrets regenerate on every page load. Want to combine stacks (e.g., Next.js + Stripe + Supabase)? Use the full generator.

How to use this .env in Kubernetes

  1. 1.Save the output as app.env.
  2. 2.Secrets: kubectl create secret generic app-secrets --from-env-file=app.env -n default.
  3. 3.Non-secret config goes into a ConfigMap: kubectl create configmap app-config --from-env-file=app.env.
  4. 4.For declarative setups, use the envFrom: field in your Deployment spec.

Gotchas

  • Split secrets from config at creation time — everything in a Secret is base64-encoded (not encrypted by default).
  • Use External Secrets Operator or sealed-secrets for production — raw Secrets in git are a leak risk.
  • envFrom: inlines every key; use env: with valueFrom: for selective mounting.

Common keys explained

APP_NAMESPACE

Kubernetes namespace for the deployment.

APP_REPLICAS

Replica count for the Deployment.

DATABASE_URL

Internal cluster DNS for the DB service.

REDIS_URL

Internal cluster DNS for Redis.

JWT_SECRET

Goes in the Secret, not the ConfigMap.

METRICS_PORT

Port the Prometheus sidecar scrapes.

Related tools

Other stacks