Configuring Kubernetes for storage volumes can be a pain, but Kubernetes hostPath makes it quick and easy! Kubernetes is an open-source system that automates deploying, managing, and scaling containerized applications.
Kubernetes provides many features to help manage your cluster of containers. One of the most useful features is Kubernetes HostPath where you can mount persistent data volumes using any directory on the node filesystem (e.g., /mnt/storage).
This blog post will show you how to mount storage volumes quickly and easily with Kubernetes HostPath!
The following deployment file will deeply an nginx image and mount a volume from the host directly inside the pod.
The name of the directory inside the deployed container is called app1.
apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: selector: matchLabels: app: web-app1 template: metadata: labels: app: web-app1 spec: containers: - name: web-app1 image: nginx volumeMounts: - name: apps1 mountPath: /apps1 volumes: - name: apps1 hostPath: path: /volumes type: Directory
If you are using Docker Desktop with WSL2 you will find the data in the path below. ( to access WSL on a Windows 10 machine use \\wsl)