Consuming entries of a ConfigMap created from property files

The example on the documentation ( for consuming values is based on a ConfigMap where each data entry is a single pair/value. Example:

apiVersion: v1
kind: ConfigMap
  name: special-config
  namespace: default
data: very
  special.type: charm

However when we create a ConfigMap from property files, every data entry value is itself a list of key/pair values. Example:

  • How to create a virtual cluster using docker on a single node?
  • Connecting Logstash and Rabbitmq docker containers
  • fig up fails with error “create_container() takes at least 2 arguments”
  • docker-compose scale with nginx and without environment variable
  • Error starting node with forever in docker container
  • nginx load balancer IP-requester based
  • $ kubectl get configmaps game-config -o yaml
    apiVersion: v1
    kind: ConfigMap
      name: game-config
    data: |-

    In such a case:

    1. How do we consume a single entry (example: enemies.cheat) as an
      environment variable?
    2. How do we consume all the entries (example: all entries)
      as a set of environment variables, assuming we just use each key as
      the environment variable name?

  • docker-compose: redis connection refused between containers
  • How to mount a docker volume while using a windows host?
  • ENTRYPOINT in Combination with CMD
  • Docker does not auto update DNS server details in /etc/resolv.conf
  • Makefile fails executing sudo docker kill
  • how to mount a Host volume to node.js docker container
  • One Solution collect form web for “Consuming entries of a ConfigMap created from property files”

    You can’t consume a single entry since it is just one big blob of text. You have two options that I see:

    1. Don’t create the config map from a file. Instead create each entry in the ConfigMap manually. You’ll have to consume each key separately though, at least until this issue is resolved.

    2. Don’t use the ConfigMap as environment variables. Instead mount that key as a volume and have your application read the key/values.

    It seems like the second option would work nicely for you. It would let you continue to generate your ConfigMap from a file, and also allow you to consume all declared key/values without having to constantly change your Kubernetes manifests.

    Another advantage of mounting your ConfigMap as a volume is that it will allow you to perform in-place updates to your configs (assuming that your app tolerates that). If you mount ConfigMap keys as environment variables the only way to update them is to restart the app.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.