After struggling to do this for an hour & reviewing these answers, I got something slightly similar to work:
First off, I am running minikube
with virtualbox
as the driver.
minikube version
minikube version: v1.9.2
My start command:
minikube start --mount=true --mount-string=$(HOME)/somedir/on/host/:/somedir/on/vm/
If you are struggling with this, I highly suggest running minikube help to see what the flags are. I suspect these could be changing for different versions/builds.
If you're looking to get this mounted directory into your pods, you must then establish a volume and volume mount in a manifest file.
Here's a simplified version of mine.
apiVersion: v1
kind: Service
...
---
apiVersion: apps/v1
kind: Deployment
...
spec:
replicas: 1
...
template:
...
spec:
containers:
...
volumeMounts:
- name: someName
mountPath: /somedir/on/vm/
...
volumes:
- name: someName
hostPath:
path: /somedir/on/vm/
Hopefully the extra polish, details and organization helps other people move a little faster on this.
Revisiting this as it seems other people like it:
If you are tied to pure minikube
, I'd suggest using the above, but I have found much better ways to locally develop minikube clusters using skaffold and docker for mac. Docker for mac can run a minikube like k8s cluster locally (in containers) using your local machine's docker daemon (so mounting files and such is a breeze). It is lovely and using it with skaffold makes hot reload and all other heavenly features possible. Do check those technologies out if you're not satisfied with the heaviness of minikube.