问题
I'm currently creating a kubernetes deployment, in this deployment I have replicas value set at X and I want to create X volume that are not empty when the corresponding pod is restarted. I'm not using any cloud provider infrastructures then please avoid command using cloud services.
I've been searching answer in kubernetes doc, and my first try was to create one huge persistent volume and one persistant volume claim per pod that are bind to the pv but it's seem's to not work...
My expectations are to have X volumes that are not shared between pods and that are not dying when pod is killed because of a liveness probe. I'm aware of any possibilities that can do the trick!
回答1:
Deployment replicas all use the same volume. There is no possibility currently to create independent volumes per replica.
StatefulSets can define volumeClaimTemplates which means one or more independent volumes per replica. For that to work StorageClass must be capable of dynamic volume provisioning.
来源:https://stackoverflow.com/questions/55807162/is-there-a-way-to-create-a-persistent-volume-per-pod-in-a-kubernetes-deployment