Aniket
Aniket

Reputation: 185

Can we connect multiple pods to the same PVC?

I mean is there a one to one or many to one relationship between pod and PVC? Can I connect two or more pods to the same PVC(persistent volume claims) without deleting or disconnecting the earlier created pods?

Upvotes: 16

Views: 35406

Answers (2)

Jonas
Jonas

Reputation: 129075

Can I connect two or more pods to the same PVC(persistent volume claims) without deleting or disconnecting the earlier created pods?

Yes, this works. But in practice this is a bit more complicated.

Persistent Volumes can be created with different access modes. Your storage system may limit what access modes you can use. E.g. the access mode ReadWriteMany is only available in some storage systems. The access mode ReadWriteOnce is most commonly available.

For multiple Pods accessing a Persistent Volume mounted with access mode ReadWriteOnce, they must be scheduled to the same node to concurrently access the volume.

For multiple Pods accessing a Persistent Volume mounted with access mode ReadWriteMany or ReadOnlyMany, the Pods can be scheduled to different nodes. But in a "cloud provider" environment, where you use multiple Availability Zones in a Region, your Persistent Volume is typically only accessible within one Availability Zone, so you must make sure that your Pods are scheduled to the same Availability Zone. Cloud providers typically offer Regional volumes as well, but they are more expensive and you need to use a specific storage class for this.

Upvotes: 21

Suresh Vishnoi
Suresh Vishnoi

Reputation: 18403

Yea, It's one of the common use case. If the PVC has a accessMode of ReadWriteMany then multiple pods can mount the volumes at the same time.

Here the access modes are:

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

for further details access-modes

Upvotes: 8

Related Questions