DCA · Question #125
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? Sol
The correct answer is A. Yes. In a single-node Kubernetes development setup, a PersistentVolume with hostPath and a corresponding PersistentVolumeClaim can successfully mount a local directory from the laptop (acting as the node) into a container.
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: Create a PersistentVolume with storageciass: "" and hostPath: /data, and a persistentVolumeClaim requesting this PV. Then use that PVC to populate a volume in a pod
Options
- AYes
- BNo
How the community answered
(34 responses)- A85% (29)
- B15% (5)
Why each option
In a single-node Kubernetes development setup, a `PersistentVolume` with `hostPath` and a corresponding `PersistentVolumeClaim` can successfully mount a local directory from the laptop (acting as the node) into a container.
For a single-node development environment where the laptop acts as the Kubernetes node, configuring a `PersistentVolume` with `hostPath: /data` and binding it via a `PersistentVolumeClaim` allows the specified directory on the host (laptop) to be mounted into a Pod's containers.
This is a valid and commonly used Kubernetes pattern for mounting directories from the host filesystem into pods, especially in local development or single-node cluster scenarios.
Concept tested: Kubernetes PersistentVolume hostPath for local development
Source: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#hostpath
Topics
Community Discussion
No community discussion yet for this question.