Kubernetes: minikube persistent volume local filesystem storage location

8/24/2020

I've read through all the docs and a few SO posts and can't find an answer to this question:

Where does minikube persist its persistent volumes in my local mac filing system?

Thanks

-- Happy Machine
kubernetes
minikube

2 Answers

9/1/2020

First of all keep in mind that Kubernetes is running on Minikube cluster. Minikube itself run on Virtual Machine, so all data would be stored in this VM not on your MacOS.

When you want to point exact place where you would like to save this data in Kubernetes you could choose between:

  • hostpath

    A hostPath volume mounts a file or directory from the host node's filesystem into your Pod. This is not something that most Pods will need, but it offers a powerful escape hatch for some applications.

  • local

A local volume represents a mounted local storage device such as a disk, partition or directory.

Local volumes can only be used as a statically created PersistentVolume. Dynamic provisioning is not supported yet.

Compared to hostPath volumes, local volumes can be used in a durable and portable manner without manually scheduling Pods to nodes, as the system is aware of the volume's node constraints by looking at the node affinity on the PersistentVolume.

However, Minikube supports only hostpath.

In this case you should check Minikube documentation about Persistent Volumes

minikube supports PersistentVolumes of type hostPath out of the box. These PersistentVolumes are mapped to a directory inside the running minikube instance (usually a VM, unless you use --driver=none, --driver=docker, or --driver=podman). For more information on how this works, read the Dynamic Provisioning section below.

minikube is configured to persist files stored under the following directories, which are made in the Minikube VM (or on your localhost if running on bare metal). You may lose data from other directories on reboots.

  • /data
  • /var/lib/minikube
  • /var/lib/docker
  • /tmp/hostpath_pv
  • /tmp/hostpath-provisioner

If you would like to mount directory from host you would need to use minikube mount.

$ minikube mount <source directory>:<target directory>

For more details, please check Minikube Mounting filesystems documentation.

-- PjoterS
Source: StackOverflow

8/24/2020

If you are using the volume type hostPath the files are saved on your node.

To access your node filesystem you can use the command: minikube ssh and under your mounted path you'll find your documents.

-- Paolo Mossini
Source: StackOverflow