0
0
Kubernetesdevops~5 mins

Using ConfigMaps as environment variables in Kubernetes - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a ConfigMap in Kubernetes?
A ConfigMap is a Kubernetes object that stores configuration data as key-value pairs. It allows you to separate configuration from container images, making apps easier to manage and update.
Click to reveal answer
beginner
How do you use a ConfigMap as environment variables in a Pod?
You reference the ConfigMap in the Pod's container spec under envFrom or env. This injects the ConfigMap's keys as environment variables inside the container.
Click to reveal answer
intermediate
What is the difference between envFrom and env when using ConfigMaps?
envFrom imports all keys from a ConfigMap as environment variables. env lets you specify individual keys from the ConfigMap as environment variables with custom names.
Click to reveal answer
beginner
Show a simple YAML snippet to use a ConfigMap named app-config as environment variables in a Pod.
apiVersion: v1 kind: Pod metadata: name: example-pod spec: containers: - name: example-container image: nginx envFrom: - configMapRef: name: app-config
Click to reveal answer
beginner
Why is it useful to use ConfigMaps for environment variables instead of hardcoding values in container images?
Using ConfigMaps lets you change configuration without rebuilding images. It keeps your containers portable and your configuration flexible, like changing settings without opening the app.
Click to reveal answer
What Kubernetes object stores key-value pairs for configuration?
AService
BPod
CDeployment
DConfigMap
Which field in a Pod spec imports all ConfigMap keys as environment variables?
AenvFrom
Bvolumes
Cenv
DconfigMapRef
How do you specify a single ConfigMap key as an environment variable with a custom name?
AUse <code>envFrom</code>
BUse <code>env</code> with <code>valueFrom.configMapKeyRef</code>
CUse <code>volumes</code>
DUse <code>configMapRef</code> in <code>volumes</code>
What happens if you update a ConfigMap used as environment variables in a running Pod?
AThe Pod environment variables do NOT update automatically
BThe Pod environment variables update immediately
CThe Pod restarts automatically
DThe ConfigMap cannot be updated
Why use ConfigMaps instead of hardcoding config in container images?
ATo make images larger
BTo increase container startup time
CTo separate config from code and update config without rebuilding images
DTo avoid using environment variables
Explain how to use a ConfigMap to provide environment variables to a Kubernetes Pod.
Think about how environment variables are set inside containers.
You got /4 concepts.
    Describe the benefits of using ConfigMaps for environment variables instead of hardcoding values in container images.
    Consider how changing settings without changing the app helps.
    You got /4 concepts.