Mount local directory into pod in minikube

前端 未结 8 463
失恋的感觉
失恋的感觉 2020-12-03 02:23

I am running minikube v0.24.1. In this minikube, I will create a Pod for my nginx application. And also I want to pass data from my local directory.

That means I wan

相关标签:
8条回答
  • 2020-12-03 03:18

    DefaultMountDir

    Minikube already mounts by default home directory to VM:

    • on Mac it mounts dir of all users - /Users
    • on Linux and Windows just the home of current user - homedir.HomeDir()

    You can see how it does this, if you browse through Minikube sources.
    Here is the search for the moment, but result might change over time:
    https://github.com/kubernetes/minikube/search?q=DefaultMountDir&unscoped_q=DefaultMountDir

    The definition of the HomeDir() is: https://godoc.org/k8s.io/client-go/util/homedir

    You can always do minikube ssh into the Minikube VM and explore it:

    $ df -hl
    Filesystem      Size  Used Avail Use% Mounted on
    ...
    /Users          466G  442G   25G  95% /Users
    

    As Minikube is a single node Kubernetes cluster, you can then mount /Users/... inside your pods.

    Recommended way

    minikube mount /path/to/dir/to/mount:/vm-mount-path is the recommended way to mount directories into minikube so that they can be used in your local Kubernetes cluster. The command works on all supported platforms.

    See documentation and example: https://minikube.sigs.k8s.io/docs/tasks/mount/

    0 讨论(0)
  • 2020-12-03 03:18

    Not sure if I joined the party late but I did a root:root mapping by doing following command:

    minikube start --mount-string="/:/"

    This just will just mount your local file system root to minikube and keeps things seamless between the systems.Hope it helps.

    0 讨论(0)
提交回复
热议问题