DCA · Question #90
You want to provide a configuration file to a container at runtime. Does this set of Kubernetes tools and steps accomplish this? Solution: Turn the configuration file into a configMap object and…
The correct answer is B. No. While using a ConfigMap is the correct approach to provide configuration files, the .spec.containers.configMounts key is an incorrect and non-existent method for mounting them into a container.
Question
You want to provide a configuration file to a container at runtime. Does this set of Kubernetes tools and steps accomplish this? Solution: Turn the configuration file into a configMap object and mount it directly into the appropriate pod and container using the .spec.containers.configMounts key.
Options
- AYes
- BNo
How the community answered
(25 responses)- A20% (5)
- B80% (20)
Why each option
While using a ConfigMap is the correct approach to provide configuration files, the `.spec.containers.configMounts` key is an incorrect and non-existent method for mounting them into a container.
The method for mounting ConfigMaps into containers is via volumes and volume mounts (`.spec.volumes` and `.spec.containers.volumeMounts`), not through a non-existent key like `.spec.containers.configMounts`.
To provide a configuration file from a ConfigMap to a container, you define the ConfigMap and then mount it into the container's filesystem using a `volume` and `volumeMount` specification under `.spec.volumes` and `.spec.containers.volumeMounts`, respectively. The `.spec.containers.configMounts` key does not exist in the Kubernetes API for mounting ConfigMaps.
Concept tested: Kubernetes ConfigMap mounting
Source: https://kubernetes.io/docs/tasks/configure-pod-container/configure-a-pod-configmap/#add-configmap-data-to-a-volume
Topics
Community Discussion
No community discussion yet for this question.