你可以将持久卷索赔挂载到已挂载的卷上吗?

huangapple go评论50阅读模式
英文:

Can you mount a Persistent Volume Claim on a mounted volume?

问题

可以在卷挂载的路径上挂载持久卷索赔。这是具有所述配置的部署示例:

      volumes:
        - name: tmp
          emptyDir: {}
        - name: pvc
          persistentVolumeClaim:
            claimName: pvc-claim-name

          volumeMounts:
            - name: tmp
              mountPath: /tmp
            - name: pvc
              mountPath: /tmp/pvc

当删除与容器一起删除的已挂载的 tmp 卷时,PVC 会被删除吗?

在已部署到已挂载卷内并将与容器一起删除的情况下,PVC 是否会保留?

英文:

Is it possible to mount a Persistent Volume Claim on the path of a volume mount. Here is an example of a deployment with said configuration:

      volumes:
        - name: tmp
          emptyDir: {}
        - name: pvc
          persistentVolumeClaim:
            claimName: pvc-claim-name

          volumeMounts:
            - name: tmp
              mountPath: /tmp
            - name: pvc
              mountPath: /tmp/pvc

Would the PVC be deleted when the mounted tmp volume is deleted with the container?

Will the PVC remain after being deployed to within a mounted volume, which will be deleted with the container?

答案1

得分: 1

是的,你可以这样做。

POD(可能你提到的是 pod,而不是容器)被删除时,不会发生任何事情,因为 Deployment 会重新部署另一个 pod 来满足副本的要求。

Deployment 被删除时,PVC 仍然存在,您的数据也将保留在文件系统中。

要删除 PVC,您需要明确删除它:

kubectl delete pvc pvc-name

但在删除 PVC 后,您的数据仍将保留在文件系统中。

请参考此页面获取更多信息。

英文:

Yes, you can do that.

When the POD (probably you was mentioning the pod, not the container) will be deleted, nothing will happen because the Deployment will re-deploy another pod to meet the replicas requirement.

When the Deployment will be deleted the PVC will remain as well as your data will remain in your filesystem.

To remove the PVC, you need to specifically delete the it:

kubectl delete pvc pvc-name

but your data persist into the filesystem after the PVC deletion.

Please, refer to this page for more information.

huangapple
  • 本文由 发表于 2023年5月15日 15:40:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76251848.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定