how volume gets mounted on POD Replica Sets

good morning 

As PV is K8s cluster resource I assume PV and PVC are the only way to attach volume to POD. then container/s inside POD can mount the same volume to container.
Query 1: If I have two replicas for my App POD, one Replicata set on NODE1 and another Replica Set on NODE2 .Does both Replica use the same PV and PVC to attach volume to both PODs ? or every replicaSet has its own PVC/PV ??
 
Query 2 : If I want to mount external storage like NAS directly to container inside POD , can I do this and if yes what would happen if POD dies and recreated ? how I can automate NAS volume mount to Container in case POD rebooted or dies ?
Solved Solved
1 3 127
1 ACCEPTED SOLUTION

Query 1: If I have two replicas for my App POD, one Replica set on NODE1 and another Replica Set on NODE2 .Does both Replica use the same PV and PVC to attach volume to both PODs ? or every replicaSet has its own PVC/PV ??

Ans : It depends on which kind of application and deployment type you are using. Basically if this is a DeploymentSet type application , then all the replicas will be using the same PVC as it is stateless and you need to use ReadwriteMany mode for PVC binding. On the otherside, if it is Stateful set application , then each replica will have unique PVC which can be setup using PVC templates.

Query 2 : If I want to mount external storage like NAS directly to container inside POD , can I do this and if yes what would happen if POD dies and recreated ? how I can automate NAS volume mount to Container in case POD rebooted or dies ?

Ans : Yes, you can attach or mount an external NAS as a PV/PVC inside a Pod as long as you create the provider's StorageClass in Kubernetes. Refer to StorageClassProvisioner  for various Storage Class provisioners. On GKE, it is recommend that , you use one of the following provisioners: 

Compute Engine PD CS

Kubernetes Filestore CSI

Regarding the Reboot of Pod, Kubernetes will perform the necessary operation on that PV/PVC according to the  Access-modes which are defined in the configuration yaml and the lifecycle-of-a-volume-and-claim 

View solution in original post

3 REPLIES 3

Query 1: If I have two replicas for my App POD, one Replica set on NODE1 and another Replica Set on NODE2 .Does both Replica use the same PV and PVC to attach volume to both PODs ? or every replicaSet has its own PVC/PV ??

Ans : It depends on which kind of application and deployment type you are using. Basically if this is a DeploymentSet type application , then all the replicas will be using the same PVC as it is stateless and you need to use ReadwriteMany mode for PVC binding. On the otherside, if it is Stateful set application , then each replica will have unique PVC which can be setup using PVC templates.

Query 2 : If I want to mount external storage like NAS directly to container inside POD , can I do this and if yes what would happen if POD dies and recreated ? how I can automate NAS volume mount to Container in case POD rebooted or dies ?

Ans : Yes, you can attach or mount an external NAS as a PV/PVC inside a Pod as long as you create the provider's StorageClass in Kubernetes. Refer to StorageClassProvisioner  for various Storage Class provisioners. On GKE, it is recommend that , you use one of the following provisioners: 

Compute Engine PD CS

Kubernetes Filestore CSI

Regarding the Reboot of Pod, Kubernetes will perform the necessary operation on that PV/PVC according to the  Access-modes which are defined in the configuration yaml and the lifecycle-of-a-volume-and-claim 

Thanks for the detailed response . I am rephrasing Query 2

Query 2 : If I want to mount external storage like NAS directly to "container" inside POD , can I do this without using PVCs and if yes what would happen if POD dies and recreated ? how I can automate NAS volume mount to Container in case POD rebooted or dies ?

If I use PV to attach storage to all nodes inside K8s cluster and then PVCs to attach storage to POD then there no question of reattachment in case of POD or Node failure.

We have use case where extra storage needed is mounted directly to Containers  without using PVC feature !

 

If I understand this correctly the volume attached/mount on Container Filesystem as below

Backend Storage(NFS/FC/iSCSI)  --> SC --> PV(Storage Volume)--> PVC (request for storage volume ) --> attach to POD --> Mount the Volume on Container File System inside POD. Example /user/mynfs 

Is it possible to use something like below 

Backend Storage(NFS/FC/iSCSI) --> Container mount point

OR

Backend Storage(NFS/FC/iSCSI)  --> SC --> PV(Storage Volume)--> mount on Container File System 

Sorry asking some stupid query as I dont have access to K8s System to perform these options

 

Top Labels in this Space
Top Solution Authors