MountVolume.SetUp failed for volume “mongo” : hostPath type check failed: /mongo/data is not a directory

后端 未结 4 1900
温柔的废话
温柔的废话 2021-01-18 23:57

I\'m trying to configure a hostPath to launch Mongodb pod.

I have only one node of kubernetes v1.8.5 installed with rancher last stable version.

I have creat

相关标签:
4条回答
  • 2021-01-19 00:16

    Changing type: Directory to type: DirectoryOrCreate works for me.

    0 讨论(0)
  • 2021-01-19 00:20

    If by any chance you are using minikube, then don't forget that minikube itself is a container. So hostPath points to a path in that container, not to a path on your host machine. You have to mount your PC path into the minikube container and then into the POD.

    Example: minikube start --mount --mount-string="/host/path:/minikubeContainer/path"

    0 讨论(0)
  • 2021-01-19 00:23

    You are creating the docker container directly on the master node. As a result of this you could be able to run docker container with the newly created directory. But when you launch the kubernetes yaml file, it intends to run on a worker node. Since you create the directory on the master node, kubelet cannot find directory on worker node and failing. That's why "DirectoryorCreate" value on type flag is a kind of solution for this.

    0 讨论(0)
  • 2021-01-19 00:26

    Removing type: Directory from the mongodb.yml works as expected

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