【问题标题】:Mountpath error: not a directory: unknown挂载路径错误:不是目录:未知
【发布时间】:2021-07-06 15:29:51
【问题描述】:

我正在 kubernetes 集群(版本 1.21.2)上使用 ceph-csi pv 和 pvc 进行测试。尝试为 dnsmasq pod 分配一个小 pv,以便能够在不重新启动 pod 的情况下更改 dnsmasq.conf。

apiVersion: v1
metadata:
  name: dnsmasq-pvc
  namespace: vt
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Mi
  storageClassName: ceph-rbd-sc
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: dnsmasq
  namespace: vt
  labels:
    app: dnsmasq
spec:
  serviceName: "dnsmasq"
  replicas: 1
  selector:
    matchLabels:
      app: dnsmasq
  template:
    metadata:
      labels:
        app: dnsmasq
    spec:
      hostname: dnsmasq
      containers:
      - name: dnsmasq
        image: jpillora/dnsmasq
        ports:
        - containerPort: 8080
        imagePullPolicy: IfNotPresent
        env:
        - name: HTTP_USER
          value: "user"
        - name: HTTP_PASS
          value: "password"
        volumeMounts:
        - mountPath: /etc/dnsmasq.conf
          name: dnsmasq-pvc
          subPath: dnsmasq.conf
      volumes:
      - name: dnsmasq-pvc
        persistentVolumeClaim:
          claimName: dnsmasq-pvc
      dnsPolicy: "None"
      dnsConfig:
        nameservers:
          - 8.8.8.8

应用 yaml 文件后,出现以下错误:

Error: failed to create containerd task: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/var/lib/kubelet/pods/48d9fac5-1603-416c-83b1-d57de22e1c81/volume-subpaths/pvc-d197a21c-107c-47a9-b334-fa4f97375b57/dnsmasq/0" to rootfs at "/etc/dnsmasq.conf" caused: mount through procfd: not a directory: unknown

我该如何解决这个问题?

【问题讨论】:

  • 必须将卷挂载为目录,不能挂载为文件。
  • 您是否尝试过包含在this answerPVC 部分)中的解决方案?另外,如果这是单个文件,您是否考虑过使用SecretConfigmap 安装为Volume (they will update eventually)。
  • 您是否以某种方式解决了这个问题?我遇到了同样的错误。提前谢谢你和问候
  • 我通过在 /etc/dnsmasq.conf 上安装一个配置为 conf-dir=/etc/dnsmasq.d,*.conf 的 ConfigMap 并将持久卷安装到 /etc/ 解决了这个问题dnsmasq.d 文件夹。

标签: kubernetes persistent-volumes dnsmasq persistent-volume-claims


【解决方案1】:
  • @jonas 提到将 volumeMount.mountPath 值修改为目录
apiVersion: v1
metadata:
  name: dnsmasq-pvc
  namespace: vt
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Mi
  storageClassName: ceph-rbd-sc
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: dnsmasq
  namespace: vt
  labels:
    app: dnsmasq
spec:
  serviceName: "dnsmasq"
  replicas: 1
  selector:
    matchLabels:
      app: dnsmasq
  template:
    metadata:
      labels:
        app: dnsmasq
    spec:
      hostname: dnsmasq
      containers:
      - name: dnsmasq
        image: jpillora/dnsmasq
        ports:
        - containerPort: 8080
        imagePullPolicy: IfNotPresent
        env:
        - name: HTTP_USER
          value: "user"
        - name: HTTP_PASS
          value: "password"
        volumeMounts:
        - mountPath: /etc/
          name: dnsmasq-pvc
          subPath: dnsmasq.conf
      volumes:
      - name: dnsmasq-pvc
        persistentVolumeClaim:
          claimName: dnsmasq-pvc
      dnsPolicy: "None"
      dnsConfig:
        nameservers:
          - 8.8.8.8

【讨论】:

  • 是的,我也尝试过喜欢您的帖子,但是当我这样做时,etc 目录中没有任何内容,因此我基本上无法对 pod 执行任何操作。
  • 可能是因为注释了 subPath。我刚刚在答案的 yaml 文件中取消了注释。你可以试试吗?
  • 可悲的是同样的事情
猜你喜欢
  • 2022-12-10
  • 1970-01-01
  • 1970-01-01
  • 2013-11-12
  • 2017-05-11
  • 1970-01-01
  • 2018-09-19
  • 2021-10-14
  • 2019-11-27
相关资源
最近更新 更多