You want to provide a configuration file to a container at runtime. Does this set of Kubernetes tools and steps accomplish this?
You want to provide a configuration file to a container at runtime. Does this set of Kubernetes tools and steps accomplish this?
Solution: Mount the configuration file directly into the appropriate pod and container using the .spec.containers.configMounts key.
A . Yes
B . No
Answer: B
Explanation:
The solution given is not a valid way to provide a configuration file to a container at runtime using Kubernetes tools and steps. The reason is that there is no such key as .spec.containers.configMounts in the PodSpec. The correct key to use is .spec.containers.volumeMounts, which specifies the volumes to mount into the container’s filesystem1. To use a ConfigMap as a volume source, one needs to create a ConfigMap object that contains the configuration file as a key-value pair, and then reference it in the .spec.volumes section of the PodSpec2. A ConfigMap is a Kubernetes API object that lets you store configuration data for other objects to use3. For example, to provide a nginx.conf file to a nginx container, one can do the following steps:
Create a ConfigMap from the nginx.conf file:
kubectl create configmap nginx-config –from-file=nginx.conf
Create a Pod that mounts the ConfigMap as a volume and uses it as the configuration file for the nginx container:
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
spec:
containers:
– name: nginx
image: nginx volumeMounts:
– name: config-volume
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
volumes:
– name: config-volume configMap:
name: nginx-config
Reference: Configure a Pod to Use a Volume for Storage | Kubernetes Configure a Pod to Use a ConfigMap | Kubernetes ConfigMaps | Kubernetes
Latest DCA Dumps Valid Version with 55 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund