Minikube/Kubernetes mountPath is not accessible

2/22/2017

I am running minikube/Kubernetes and am having difficulty accessing a volume from a volumeMount in a deployment.

I can confirm that when the microservice starts up, it is not able to access the /config directory (ie. the "mountPath" in the "volumeMounts"). I have verified that the hostPath/path is valid.

I have experimented with a number of techniques and have also validated that the deployment files is correct. I have also tried using quotes/double-quotes/no-quotes around the path specifications, but this does not address the issue.

Note that I am using a "hostPath" for simple testing purposes, however, this is the scenario that I nevertheless need to address.

My minikube configuration is illustrated below:

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"08e099554f3c31f6e6f07b448ab3ed78d0520507", GitTreeState:"clean", BuildDate:"2017-01-12T07:30:54Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"08e099554f3c31f6e6f07b448ab3ed78d0520507", GitTreeState:"clean", BuildDate:"1970-01-01T00:00:00Z", GoVersion:"go1.7.1", Compiler:"gc", Platform:"linux/amd64"}

I am running minikube on MacOS/Sierra version 10.12.3 (16D32).

My deployment file (deployment.yaml):

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: atmp1000-deployment
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: atmp1000
    spec:
      containers:
      - name: atmp1000
        image: atmp1000
        ports:
        - containerPort: 7010
        volumeMounts:
          - name: atmp1000-volume
            mountPath: '/config'
      volumes:
      - name: atmp1000-volume
        hostPath:
          path: '/Users/<username>/<some-path>/config'

Any help is appreciated.

-- Eric Broda
kubernetes
minikube

2 Answers

2/22/2017

Host mounting directories is not supported by minikube yet. Please check https://github.com/kubernetes/minikube/issues/2

Internally minikube uses a virtual machine to host Kubernetes. If you specify hostPath in a POD spec, Kubernetes will host mount the specified directory inside the VM and not the directory on your actual host.

If you really need to access something on your host machine, you have to use NFS or any other network based volume type.

-- Alexander Block
Source: StackOverflow

2/24/2017

In the interest of completeness, below is the solution that I found... I got the hostPath and mounts working on minikube (on Mac) which took a few steps but required several "minikube delete" commands to get the most current version and reset the environment. Below are some additional notes about how to get this functioning:

  • I had to use the xhyve driver to make it all work properly -- it probably works using other drivers but I did not try them.

  • I found that minikube mounts host paths at "/User" which means the "volumes/hostPath/path" should start at "/User"

  • I found a variety of ways that this worked including using claims but the files in the original question now reflect a correct and simple configuration.

-- Eric Broda
Source: StackOverflow