Schedule a chat

Auto-generate Kubernetes ConfigMaps from Environr

May 14, 2018

Kubernetes ConfigMaps are a convenient way to encapsulate configuration values into a named resource and then access those values in your application as environment variables. Creating these resources, however, is typically a manual process, requiring either manually writing YAML or ingesting directories or files containing the values.

Today, the most recent version of Environr’s CLI added support for a new output format: kubernetes-configmap.

Invoking the CLI tool with the kubernetes-configmap outputter generates a Kubernetes ConfigMap with the same name as the Environr configuration set.


> environr-cli env k8s-example --env-output=kubernetes-configmap
apiVersion: v1
data:
  host: host.example.org
  key1: value1
  key2: value2
  key3: value3
kind: ConfigMap
metadata:
  name: k8s-example


This can be used to easily create the YAML for a ConfigSet, but it can equally be used to apply a ConfigSet directly to Kubernetes using kubectl:


> kubectl apply -f <(environr-cli env k8s-example --env-output=kubernetes-configmap)
configmap "k8s-example" created

Do note, however, that if your configuration includes secrets, it should not be crafted into a ConfigMap. Until Environr supports some type of separation between general configuration values and secrets, you’re best to keep general configuration values and secrets in separate configs.

Take a peek at the documentation for more information on importing and building configuration sets.

comments powered by Disqus