我的 Pod 声明了两个不同的卷。
我使用一些定义模板,并且根据某些情况的环境,我想对两个卷重复使用相同的声明。
这会导致错误:
Unable to mount volumes for pod "task-pv-pod_<...>": timeout expired waiting for volumes to attach/mount for pod "<...>"/"task-pv-pod". list of unattached/unmounted volumes=[task-pv-storage1]
Run Code Online (Sandbox Code Playgroud)
这是一个简化的 pod 定义:
kind: Pod
apiVersion: v1
metadata:
name: task-pv-pod
spec:
volumes:
- name: task-pv-storage1
persistentVolumeClaim:
claimName: task-pv-claim
- name: task-pv-storage2
persistentVolumeClaim:
claimName: task-pv-claim
containers:
- name: task-pv-container
image: nginx
ports:
- containerPort: 80
name: "http-server"
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: task-pv-storage1
- mountPath: "/usr/share/nginx/something-else"
name: task-pv-storage2
Run Code Online (Sandbox Code Playgroud)
那么为什么它不起作用呢?
mount kubernetes mounted-volumes persistent-volumes persistent-volume-claims