1

我正在运行 minikube/Kubernetes,并且在部署中从 volumeMount 访问卷时遇到困难。

我可以确认,当微服务启动时,它无法访问 /config 目录(即“volumeMounts”中的“mountPath”)。我已经验证了 hostPath/path 是有效的。

我已经尝试了多种技术,并且还验证了部署文件是正确的。我也尝试在路径规范周围使用引号/双引号/无引号,但这并不能解决问题。

请注意,我将“hostPath”用于简单的测试目的,但是,这是我仍然需要解决的场景。

我的 minikube 配置如下图所示:

$ 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"}

我在 MacOS/Sierra 版本 10.12.3 (16D32) 上运行 minikube。

我的部署文件(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'

任何帮助表示赞赏。

4

2 回答 2

1

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.

于 2017-02-24T23:02:16.583 回答
0

minikube 还不支持主机挂载目录。请查看https://github.com/kubernetes/minikube/issues/2

minikube 在内部使用虚拟机来托管 Kubernetes。如果您hostPath在 POD 规范中指定,Kubernetes 将在 VM 内托管指定目录,而不是实际主机上的目录。

如果您确实需要访问主机上的某些内容,则必须使用 NFS 或任何其他基于网络的卷类型。

于 2017-02-22T20:39:37.287 回答