英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论