0
0
Kubernetesdevops~20 mins

Using ConfigMaps as mounted volumes in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ConfigMap Volume Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of Pod with ConfigMap volume mount
Given the following Pod YAML snippet mounting a ConfigMap as a volume, what will be the content of the file /etc/config/app.properties inside the container?
Kubernetes
apiVersion: v1
kind: Pod
metadata:
  name: configmap-volume-pod
spec:
  containers:
  - name: test-container
    image: busybox
    command: ["cat", "/etc/config/app.properties"]
    volumeMounts:
    - name: config-volume
      mountPath: /etc/config
  volumes:
  - name: config-volume
    configMap:
      name: app-config
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  app.properties: |
    key1=value1
    key2=value2
AError: file not found
B
app.properties
C
key1=value1
key2=value2
app.properties
D
key1=value1
key2=value2
Attempts:
2 left
💡 Hint
Remember that mounting a ConfigMap as a volume creates files named after the keys with their content as the file content.
🧠 Conceptual
intermediate
1:30remaining
Behavior of ConfigMap volume updates in running Pods
If a ConfigMap used as a mounted volume in a running Pod is updated, what happens to the files inside the Pod's volume?
AThe files inside the Pod update automatically within a few seconds.
BThe files inside the Pod never update until the Pod is restarted.
CThe files update only if the Pod's container is manually restarted.
DThe files update only if the ConfigMap is deleted and recreated.
Attempts:
2 left
💡 Hint
Think about how Kubernetes syncs ConfigMap volumes with the cluster state.
Configuration
advanced
2:30remaining
Correct YAML for mounting multiple ConfigMap keys as files
Which YAML snippet correctly mounts only the keys config1 and config2 from a ConfigMap named multi-config as files inside /etc/config in a Pod?
A
volumes:
- name: config-volume
  configMap:
    name: multi-config
    items:
    - path: config1
    - path: config2
containers:
- name: app
  volumeMounts:
  - name: config-volume
    mountPath: /etc/config
B
volumes:
- name: config-volume
  configMap:
    name: multi-config
    keys:
    - config1
    - config2
containers:
- name: app
  volumeMounts:
  - name: config-volume
    mountPath: /etc/config
C
volumes:
- name: config-volume
  configMap:
    name: multi-config
    items:
    - key: config1
      path: config1
    - key: config2
      path: config2
containers:
- name: app
  volumeMounts:
  - name: config-volume
    mountPath: /etc/config
D
volumes:
- name: config-volume
  configMap:
    name: multi-config
    keys:
    - key: config1
    - key: config2
containers:
- name: app
  volumeMounts:
  - name: config-volume
    mountPath: /etc/config
Attempts:
2 left
💡 Hint
Look for the correct use of the 'items' field with 'key' and 'path' under configMap.
Troubleshoot
advanced
2:00remaining
Troubleshooting missing ConfigMap files in Pod
A Pod mounts a ConfigMap as a volume, but inside the container the expected files are missing. Which is the most likely cause?
AThe ConfigMap does not exist or has a different name than specified in the volume.
BThe container image does not support ConfigMap volumes.
CThe Pod's service account lacks permissions to read ConfigMaps.
DThe volumeMount path is not an absolute path.
Attempts:
2 left
💡 Hint
Check if the ConfigMap name matches exactly and exists in the same namespace.
🔀 Workflow
expert
3:00remaining
Steps to update ConfigMap data and apply changes to running Pods
What is the correct sequence of commands to update a ConfigMap named app-config with new data from a file new-config.properties and ensure running Pods using it get the updated content?
A2,1,3,4
B1,2,3,4
C1,3,2,4
D3,1,2,4
Attempts:
2 left
💡 Hint
First generate updated ConfigMap YAML, then apply it, then restart Pods to pick changes.