0
0
Kubernetesdevops~20 mins

Using ConfigMaps as environment variables in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ConfigMap Env Vars Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of Pod Environment Variables from ConfigMap
Given a ConfigMap named app-config with key-value pairs, and a Pod manifest that uses this ConfigMap as environment variables, what will be the output of printenv inside the Pod?
Kubernetes
apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  LOG_LEVEL: DEBUG
  MAX_RETRIES: "5"
---
apiVersion: v1
kind: Pod
metadata:
  name: test-pod
spec:
  containers:
  - name: test-container
    image: busybox
    command: ["sh", "-c", "printenv"]
    envFrom:
    - configMapRef:
        name: app-config
ALOG_LEVEL=DEBUG\nMAX_RETRIES=5 (without quotes)\n... (other default env vars)
BLOG_LEVEL=DEBUG\nMAX_RETRIES=5\n... (other default env vars)
CNo environment variables from ConfigMap are set
DLOG_LEVEL=DEBUG\nMAX_RETRIES="5"\n... (other default env vars)
Attempts:
2 left
💡 Hint
Remember that ConfigMap values are strings and environment variables are strings without quotes.
Configuration
intermediate
2:00remaining
Correct ConfigMap Reference in Pod Spec
Which of the following Pod specs correctly injects environment variables from a ConfigMap named my-config?
A
envFrom:
- configMapRef:
    name: my-config
B
env:
- name: my-config
  valueFrom:
    configMapKeyRef:
      name: my-config
      key: my-config
C
envFrom:
- secretRef:
    name: my-config
D
env:
- name: my-config
  value: my-config
Attempts:
2 left
💡 Hint
Check the correct field name for referencing ConfigMaps in envFrom.
Troubleshoot
advanced
2:00remaining
Why Are ConfigMap Environment Variables Missing in Pod?
A Pod references a ConfigMap named settings using envFrom, but the environment variables are not available inside the container. What is the most likely cause?
AThe container image does not support environment variables
BThe Pod spec uses <code>envFrom: secretRef</code> instead of <code>configMapRef</code>
CThe ConfigMap <code>settings</code> does not exist in the same namespace as the Pod
DThe ConfigMap keys are empty strings
Attempts:
2 left
💡 Hint
ConfigMaps are namespace-scoped resources.
🔀 Workflow
advanced
3:00remaining
Order of Steps to Update ConfigMap Environment Variables in Running Pod
What is the correct order of steps to update environment variables from a ConfigMap in a running Pod?
A4,2,1,3
B4,1,2,3
C1,2,4,3
D1,4,2,3
Attempts:
2 left
💡 Hint
Remember to apply changes before deleting the Pod to pick up new config.
Best Practice
expert
2:30remaining
Best Practice for Managing Sensitive Data with ConfigMaps as Environment Variables
Which approach is best practice when using ConfigMaps for environment variables that include sensitive data like passwords?
AStore sensitive data in Secrets and reference them separately from ConfigMaps
BStore sensitive data in ConfigMaps and use RBAC to restrict access
CEncode sensitive data in base64 and store in ConfigMaps
DStore sensitive data directly in Pod specs as environment variables
Attempts:
2 left
💡 Hint
Consider Kubernetes resource types designed for sensitive data.