A ConfigMap web-conf has the key nginx.conf. You want to place only that file at /etc/nginx/nginx.conf without hiding the other files in /etc/nginx. Which container volume mount does this?
- A.
volumeMounts: - name: conf mountPath: /etc/nginx - B.
volumeMounts: - name: conf mountPath: /etc/nginx/nginx.conf subPath: nginx.conf - C.
volumeMounts: - name: conf mountPath: /etc/nginx/nginx.conf - D.
volumeMounts: - name: conf mountPath: /etc/nginx subPath: nginx.conf
Show answer and explanation
Answer: B
subPath mounts a single file from the volume at the exact mountPath, leaving the rest of the directory intact. (Files mounted with subPath do not receive ConfigMap updates.)
- Mounting the whole volume on
/etc/nginxhides the existing directory contents. - Without
subPath,/etc/nginx/nginx.confbecomes a directory containing the key. - The last option mounts the file at the directory path.