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.

Command using File

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

Example

Input File

# application.properties
FOO=Bar

Command

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

Output

$ kubectl get configmap

NAME        DATA   AGE
my-config   1      21s

Command using Literal

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

Example

Command

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

Output

$ kubectl get configmap

NAME        DATA   AGE
my-config   1      21s

Command using env file

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

Example

Input File

# tracing.env
ENABLE_TRACING=true
SAMPLER_TYPE=probabilistic
SAMPLER_PARAMETERS=0.1

Command

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

Output

$ kubectl get configmap

NAME        DATA   AGE
my-config   1      21s


Last modified February 15, 2021: Update _index.md (95b1dcc)