小编egt*_*egt的帖子

Kubernetes 中的两个卷是否可以具有相同的 PVC?

我的 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 中重复使用相同的声明。

这是一个简化的 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

8
推荐指数
2
解决办法
5690
查看次数