DCA · Question #124
During development of an application meant to be orchestrated by Kubernetes, you want to mount the /data directory on your laptop into a container. Will this strategy successfully accomplish this?…
The correct answer is B. No. A hostPath volume in Kubernetes mounts a directory from the node's filesystem, not directly from a developer's local laptop unless the laptop is the Kubernetes node itself.
Question
During development of an application meant to be orchestrated by Kubernetes, you want to mount the /data directory on your laptop into a container. Will this strategy successfully accomplish this? Solution: Add a volume to the pod that sets hostPath.path: /data, and then mount this volume into the pod's containers as desired.
Options
- AYes
- BNo
How the community answered
(47 responses)- A19% (9)
- B81% (38)
Why each option
A `hostPath` volume in Kubernetes mounts a directory from the *node's* filesystem, not directly from a developer's local laptop unless the laptop is the Kubernetes node itself.
While `hostPath` enables host filesystem mounts, it refers to the filesystem of the Kubernetes worker node, not a separate local development machine.
A `hostPath` volume in Kubernetes mounts a file or directory from the host *node* where the Pod is scheduled, not from an arbitrary developer's local laptop, thus this strategy alone will not mount the laptop's `/data` directory unless the laptop is the Kubernetes host.
Concept tested: Kubernetes hostPath volume semantics
Source: https://kubernetes.io/docs/concepts/storage/volumes/#hostpath
Topics
Community Discussion
No community discussion yet for this question.