Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minikube volumes

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 ?

like image 862
Tristan Avatar asked Feb 25 '17 12:02

Tristan


People also ask

Where does minikube store 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 ).

What is volumes in Kubernetes?

A Kubernetes volume is a directory that contains data accessible to containers in a given Pod in the orchestration and scheduling platform. Volumes provide a plug-in mechanism to connect ephemeral containers with persistent data stores elsewhere.

How big is minikube?

The answer is Minikube, which can help you easily set up a proper Kubernetes node suitable for your everyday development needs. To get going, the minikube start command just brings up a single-node Kubernetes environment with 2GB RAM, 2 CPUS, and a disk of 20GB.


1 Answers

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.

like image 139
helmbert Avatar answered Sep 28 '22 04:09

helmbert