Tim Schwalbe
Tim Schwalbe

Reputation: 1746

Kubernetes set environment variables depending on namespace

I want to set specific env variables depending on the namespace.

The goal is to have one config yaml file for different namespaces and set different env variables/config maps for dev, qa and prod depending on the namespace which the config file is applied to.

Upvotes: 0

Views: 789

Answers (1)

Eugene Chow
Eugene Chow

Reputation: 1706

Afaik, kubernetes doesn't come with this capability out of the box.

There are two ways to get around this:

  1. Deploy a standard ConfigMap that contains everything any deployment needs. Make your app recognise the namespace and use the appropriate variable.
  2. Deploy a sidecar app that generates a namespace-specific ConfigMap from a template. This sidecar will need access to kube-apiserver to deploy new ConfigMap manifests automatically.

Upvotes: 2

Related Questions