【问题标题】:Cannot see volume content in a hostPath mount在 hostPath 挂载中看不到卷内容
【发布时间】:2018-05-14 15:41:51
【问题描述】:

我有这个非常简单的容器图像:

FROM nvidia/cuda:8.0-runtime-centos7
VOLUME ["/myvolume"]

# hack to keep the container alive and listening...
CMD exec /bin/bash -c "trap : TERM INT; sleep infinity & wait"

我想通过 Kubernetes 将它部署到 minikube 0.25.2(在 Windows 10 上)。 我希望将/myvolume 挂载到主机路径c:\TestDir\(使用语法/c/TestDir/)。 TestDir 与任何拥有完全控制权的人共享。

我使用“Persistent Volume Claims”来达到目的。这是我使用的 .yaml:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    run: hello-mount
  name: hello-mount
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      run: hello-mount
  template:
    metadata:
      labels:
        run: hello-mount
    spec:
      containers:
      - image: docker.io/myid/host_mount_img
        name: hello-mount
        volumeMounts:
        - name: myvolumelbl
          mountPath: /myvolume
      volumes:
      - name: myvolumelbl
        persistentVolumeClaim:
          claimName: data-pvc
---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: data-pv
spec:
  accessModes:
    - ReadWriteMany
  capacity:
    storage: 2Mi
  hostPath:
    path: /c/TestDir/
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: data-pvc
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Mi
  volumeName: data-pv

根据 kubernetes 仪表板,/myvolume 已正确挂载到 /c/TestDir 但是当我进入 pod 目录 /myvolume 是空的 - 即我看不到 /c/TestDir 的内容

欢迎任何帮助......

【问题讨论】:

  • 您能否提供更多信息:您使用哪个 vm-driver 来启动 minikube。因为有两种方法可以解决问题。
  • Hyper-V(查看 Hyper-V 管理器似乎没问题)

标签: docker kubernetes


【解决方案1】:

它看起来像issue with minikube on Hyper-V。它没有解决它。所以我给你的建议是:尝试使用 VirtualBox vm-driver。

在 VirtualBox 中创建一个共享文件夹并将其用作 Persistent Volume。

【讨论】:

    猜你喜欢
    • 2018-01-09
    • 2018-12-02
    • 1970-01-01
    • 1970-01-01
    • 2021-04-11
    • 1970-01-01
    • 2018-04-18
    • 1970-01-01
    • 2017-07-21
    相关资源
    最近更新 更多