configmap

Creating non-confidential key-value pair data in clusters

A ConfigMap is an API object used to store non-confidential data in key-value pairs. Pods can consume ConfigMaps as environment variables, command-line arguments, or as configuration files in a volume.

A ConfigMap allows you to decouple environment-specific configuration from your container images, so that your applications are easily portable.

Warning

ConfigMap does not provide secrecy or encryption. If the data you want to store are confidential, use a Secret rather than a ConfigMap, or use additional (third party) tools to keep your data private.

Command using File

  1. kubectl create configmap my-config --from-file=path/to/bar

Example

Input File

  1. # application.properties
  2. FOO=Bar

Command

  1. kubectl create configmap my-config --from-file=application.properties

Output

  1. $ kubectl get configmap
  2. NAME DATA AGE
  3. my-config 1 21s

Command using Literal

  1. kubectl create configmap my-config --from-literal=key1=config1 --from-literal=key2=config2

Example

Command

  1. kubectl create configmap my-config --from-literal=FOO=Bar

Output

  1. $ kubectl get configmap
  2. NAME DATA AGE
  3. my-config 1 21s

Command using env file

  1. kubectl create configmap my-config --from-env-file=path/to/bar.env

Example

Input File

  1. # tracing.env
  2. ENABLE_TRACING=true
  3. SAMPLER_TYPE=probabilistic
  4. SAMPLER_PARAMETERS=0.1

Command

  1. kubectl create configmap my-config --from-file=tracing.env

Output

  1. $ kubectl get configmap
  2. NAME DATA AGE
  3. my-config 1 21s