【问题标题】:Kubernetes Storage type Hostpath- files mapping issueKubernetes 存储类型 Hostpath- 文件映射问题
【发布时间】:2019-01-08 19:17:54
【问题描述】:

您好,我正在使用最新的 kubernetes 1.13.1 和 docker-ce(Docker 版本 18.06.1-ce,构建 e68fc7a)。

我设置了一个部署文件,该文件从主机(主机路径)挂载文件并将其挂载到容器中(挂载路径)。

错误是,当我尝试将查找从主机挂载到容器时,我收到一条错误消息,指出它不是文件。 (Kubernetes由于某种原因认为该文件是一个目录)

当我尝试使用以下命令运行容器时: Kubectl 创建 -f 它永远停留在 ContainerCreating 阶段。

使用 Kubectl describe pod 对其进行深入研究后,它会说:
有一条错误消息表明该文件未被识别为文件。

这是部署文件:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: notixxxion
  name: notification
spec:
  replicas: 1
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: notification
    spec:
      containers:
      - image: docker-registry.xxxxxx.com/xxxxx/nxxxx:laxxt
        name: notixxxion
        ports:
        - containerPort: xxx0
####   host file configuration
        volumeMounts:
        - mountPath: /opt/notification/dist/hellow.txt
          name: test-volume
          readOnly: false
      volumes:
      - name: test-volume
        hostPath:
        # directory location on host
          path: /exec-ui/app-config/hellow.txt
        # this field is optional
          type: FileOrCreate
          #type: File
status: {}

【问题讨论】:

  • 在您的问题中很难读懂您正在运行哪些命令以及什么是文件。使用反引号来注释文字命令,并为代码块使用三次反引号。

标签: docker kubernetes


【解决方案1】:

我已经重新安装了 kubernetes 集群,它变得更好了。 kubernetes 现在可以毫无问题地读取文件并且容器在创建和运行中但是,主机路径存储类型还有一些其他问题:

包含挂载的 hostPath 不会更新,因为它们在主机上发生了变化,即使我删除了 pod 并再次创建它

【讨论】:

    【解决方案2】:

    检查您尝试挂载的文件权限!

    作为最后的手段尝试使用特权模式。

    希望对你有帮助!

    【讨论】:

    • 我已经检查了权限并且它归根用户所有。 744.在容器内,我可以访问 root 拥有的文件。
    猜你喜欢
    • 2018-01-11
    • 2021-07-23
    • 2016-01-14
    • 2013-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-09
    • 1970-01-01
    相关资源
    最近更新 更多