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
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-file=tracing.env
Output
$ kubectl get configmap
NAME DATA AGE
my-config 1 21s
当前内容版权归 kubernetes官网 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 kubernetes官网 .