【发布时间】: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 answer(
PVC部分)中的解决方案?另外,如果这是单个文件,您是否考虑过使用Secret或Configmap安装为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