Hai semuanya, di materi kali ini kita akan membahas tentang mount your data from workstation to minikube cluster. Mounting data ini berguna untuk bind files dari container ke volume ataupun sebaliknya (mount-bind). Dengan menggunakan minikube kita bisa menggunakan 2 cara yaitu:

  1. Using 9P Mounts
  2. Using Driver mounts

Ok langsung aja kita bahas materi yang pertama:

Using 9P Mounts

9P mounts are flexible and work across all hypervisors, but suffers from performance and reliability issues when used with large folders (>600 files).

To mount a directory from the host into the guest using the mount subcommand:

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

For example, this would mount your working directory to appear as /volumes within the minikube VM:

Jika dijalankan hasilnya seperti berikut:

 youtube git:(master) minikube mount .\_posts\kubernetes\02-getting-started\:/volumes
📁  Mounting host path .\_posts\kubernetes\02-getting-started\ into VM as /volumes ...
     Mount type:
     User ID:      docker
     Group ID:     docker
     Version:      9p2000.L
     Message Size: 262144
     Options:      map[]
     Bind Address:
🚀  Userspace file server: ufs starting
  Successfully mounted .\_posts\kubernetes\02-getting-started\ to /volumes

 ~  minikube ssh
docker@minikube:~$ ls /volumes/

This directory may then be referenced from a Kubernetes manifest, for example:

Using Driver mounts

Some hypervisors, have built-in host folder sharing. Driver mounts are reliable with good performance, but the paths are not predictable across operating systems or hypervisors:

Driver OS HostFolder VM
VirtualBox Linux /home /hostname
VirtualBox macOs /Users /Users
VirtualBox Windows C://Users /c/Users
KVM Linux Unsupported -
HyperKit Linux Unsupported -

These mounts can be disabled by passing --disable-driver-mounts to minikube start.

Jika kita coba, seperti berikut:

## my workspaces
➜  ~ ls Workspaces/examples 

## inside minikube cluster
➜  ~ minikube ssh
$ ls /hosthome/dimasm93/Workspaces/examples/