首页 > 解决方案 > 带有 directoryOrCreate 的 Kubernetes hostPath 不起作用

问题描述

我正在尝试创建一个hostPath用于卷的简单 pod。
设置非常简单:

apiVersion: apps/v1
kind: DaemonSet
...
spec:
  template:
    spec:
      containers:
        - name: test
          ...
          volumeMounts:
          - name: mntdatas3fs
            mountPath: /var/s3:shared
            ...
      volumes:
      - name: devfuse
        hostPath:
          path: /dev/fuse
      - name: mntdatas3fs
        hostPath:
          path: "/mnt/s3bucket/my_backet"
          type: DirectoryOrCreate          

在第一次运行时 - 一切正常,目录按应有的方式创建。
但是如果我删除这个 pod 并重新创建它,它将无法运行并出现以下错误:
Error: failed to start container "storage-mount": Error response from daemon: error while creating mount source path '/mnt/s3bucket/my_backet': mkdir /mnt/s3bucket/my_backet: file exists

标签: kubernetes

解决方案


推荐阅读