Skip to main content

Kubernetes: where does each config variable actually live?

Kubernetes

Deploying on Kubernetes forced me to clarify a simple question: where does each config variable live? ๐Ÿ”‘

My mental grid, applied to this website (Symfony + Next.js on k8s):

  • ๐Ÿ”น k8s Secret: anything sensitive and read at runtime. SMTP credentials, secret API keysโ€ฆ The pod receives them as environment variables โ€” nothing in the image, nothing in the repo.
  • ๐Ÿ”น ConfigMap: non-sensitive config that varies per environment.
  • ๐Ÿ”น Docker build-arg: what must be frozen into the artifact at build time โ€” typically the NEXT_PUBLIC_* variables of a Next.js frontend, compiled into the JS bundle.

The question to ask for every variable: "Who consumes it, and when?" The server at runtime โ†’ Secret/ConfigMap. The client's browser โ†’ it must be there at build time.

Picking the wrong box means either a secret key exposed in a public bundle, or a frontend pointing at localhost in production. Both cost you dearly. ๐Ÿ˜ฌ

See the original post on LinkedIn