13

Minikube is supposed to make it simple to run Kubernetes locally, not only for "getting started" but also for "day-to-day development workflows".

source : https://github.com/kubernetes/minikube/blob/master/ROADMAP.md#goals

But I can also read that : "PersistentVolumes are mapped to a directory inside the minikube VM. The Minikube VM boots into a tmpfs, so most directories will not be persisted across reboots (minikube stop)"

source : https://kubernetes.io/docs/getting-started-guides/minikube/#persistent-volumes

So what if my developments need persistent storage (MySQL database, mongodb database, ...) ? Do I need to throw my Minikube and install directly the full Kubernetes ?

Tristan
  • 8,733
  • 7
  • 48
  • 96

3 Answers3

20

This is covered in the documentation. The relevant section starts right after the sentence that you've already quoted:

However, Minikube is configured to persist files stored under the following host directories:

  • /data
  • /var/lib/localkube
  • /var/lib/docker

Here is an example PersistentVolume config to persist data in the ‘/data’ directory:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv0001
spec:
  accessModes:
    - ReadWriteOnce
  capacity:
    storage: 5Gi
  hostPath:
    path: /data/pv0001/

Simply declare hostPath volumes that are mapped to any directory in /data on the host, and these should persist across reboots.

helmbert
  • 35,797
  • 13
  • 82
  • 95
  • "should" ? so you don't know more than me right ? Cause what I understand is you can create volumes but the "host" will be minikube VM, that's what is written in the documentation you've just quoted. – Tristan Feb 25 '17 at 14:41
  • To be clear, you say : "Simply declare hostPath volumes", when doc says : "Minikube supports PersistentVolumes of type hostPath. These PersistentVolumes are mapped to a directory inside the minikube VM." – Tristan Feb 25 '17 at 14:46
  • "These PersistentVolumes are mapped to a directory inside the minikube VM." -- Yes. And the doc says that this directory is persisted across reboots of the Minikube VM. That what you've asked for in your question, wasn't it? – helmbert Feb 25 '17 at 14:55
  • Are we reading the same doc ? Mine says : "most directories will NOT be persisted across reboots" – Tristan Feb 25 '17 at 15:06
  • 2
    Yes. But `/data/` will. – helmbert Feb 25 '17 at 15:10
  • After a discussion with some minikube guy, he has made a pull request to correct the misleading documentation (You are right about /data/ though). – Tristan Feb 28 '17 at 08:01
  • as of 2022SEP document url should be changed to https://minikube.sigs.k8s.io/docs/handbook/persistent_volumes/ – Max Sep 14 '22 at 09:24
10

Here is the answer from a Minikube contributer, confirming there was a problem in the documentation :

I've reworded the readme to make a little more sense.

The host is the computer you're running minikube on. This is only exposed to the VM through the mounted host folders https://github.com/kubernetes/minikube/blob/master/docs/host_folder_mount.md

The guest, or minikube VM, will persist certain folders to a disk stored on the host (something like ~/.minikube/machines/minikube/disk.vmdk). Files stored in certain directories in the minikube VM will persist between start/stops, but not deletes.

source : https://github.com/kubernetes/minikube/issues/1184

wltheng
  • 750
  • 1
  • 11
  • 26
Tristan
  • 8,733
  • 7
  • 48
  • 96
-4

Or you can try https://github.com/reachlin/k8s0/, which is a full-fledged kubernetes installed on a single host using ansible.

reachlin
  • 4,516
  • 7
  • 18
  • 23