Challenge - 5 Problems
ConfigMap Env Vars Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediateOutput 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
Attempts:
2 left
💡 Hint
Remember that ConfigMap values are strings and environment variables are strings without quotes.
✗ Incorrect
ConfigMap values are injected as strings without quotes in environment variables. The value "5" is interpreted as the string 5 without quotes in the environment.
❓ Configuration
intermediateCorrect ConfigMap Reference in Pod Spec
Which of the following Pod specs correctly injects environment variables from a ConfigMap named
my-config?Attempts:
2 left
💡 Hint
Check the correct field name for referencing ConfigMaps in envFrom.
✗ Incorrect
The correct way to inject all keys from a ConfigMap as environment variables is using envFrom with configMapRef and the ConfigMap name.
❓ Troubleshoot
advancedWhy 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?Attempts:
2 left
💡 Hint
ConfigMaps are namespace-scoped resources.
✗ Incorrect
ConfigMaps must exist in the same namespace as the Pod to be referenced. If missing, environment variables won't be injected.
🔀 Workflow
advancedOrder 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?
Attempts:
2 left
💡 Hint
Remember to apply changes before deleting the Pod to pick up new config.
✗ Incorrect
First update the ConfigMap locally, then apply it to the cluster, delete the Pod to recreate it with new env vars, then verify.
✅ Best Practice
expertBest 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?
Attempts:
2 left
💡 Hint
Consider Kubernetes resource types designed for sensitive data.
✗ Incorrect
Kubernetes Secrets are designed for sensitive data and provide better security than ConfigMaps.
