I have setup a deployment (dep1) in k8s and there's a persistent volume associated with it with access mode ReadWriteOnce. I have a HorizontalPodAutoscale resource with the dep1 which auto-scales the deployment if CPU consumption is above a certain threshold. What would happen if the deployments are deployed across multiple nodes? Would auto-scaling work? In general, is there any concern regarding autoscaling when using PVs in ReadWriteOnce mode?
I didn't try this myself yet but I guess it depends on which type of volume you work with. If you work with an ebs
as PV, then mounts across nodes at the same time aren't possible and the pods will fail if they are scheduled on different nodes. If you use a nfs
type of volume on the other hand, then mounts on multiple nodes are possible.
That being said, I think you have to overthink your access mode policy. ReadWriteOnce
per definition allows only a mount by a single node. I think in your scenario you would need to change to ReadWriteMany
.
This is the definition of the Access Modes
ReadWriteOnce – the volume can be mounted as read-write by a single node
ReadOnlyMany – the volume can be mounted read-only by many nodes
ReadWriteMany – the volume can be mounted as read-write by many nodes
Some Volume type can only be mounted ReadWriteOnce
on a single node at a time (e.g EBS) and as such will not allow autoscaling by node if the volume is already claimed by pod on another node, while others can be mounted on many nodes ReadWriteMany
(e.g NFS) and as such allows auto scaling by node.
See table below
https://kubernetes.io/docs/concepts/storage/persistent-volumes/