Can kubernetes volumes be used for deployments? If so what happens if each pod is on different host?

12/25/2021

Can we use kubernetes volumes for deployments? If yes than that will be mutliple pods sharing the same volume? If that is possible then what happens when all the pods for the deployment are on different host machines? Especially when using Amazon EBS where an ebs volume cannot be shared across multiple hosts.

-- Arpan Solanki
kubernetes
persistent-volume-claims
persistent-volumes

1 Answer

12/25/2021
  • Yes, you can use a persistent volume for deployments
  • Such a volume will be mounted to your desired location in all the pods
  • If you use EBS block storage, all your pods will need to be scheduled on the same node where you have attached your volume. This may not work if you have many replicas
  • You will have to use a network file storage, such as EFS, GlusterFS, Portworx, etc. with ReadWriteMany if you want your pods to be spun up on different nodes
  • EBS will give you the best performance with the aforementioned single node limitation
-- Rakesh Gupta
Source: StackOverflow