Behavior of persistent volume as volume type in GCP

4/26/2020

I have created a jenkins installation via its official helm chart on GKE.

As it is evident from the deployment, it will create a PVC to mount the jenkins home path (i.e. /var/jenkins_jome) to the persistent disk.

I am creating a GCP persistent disk for this purpose. (it will either way create it automatically since the provisioning is done on a cloud provider).

My question is the following (and is kubernetes specific, not directly related to jenkins)

Since the PD (on which the corresponding PV/PVC are created) is attached to a node, what happens if the jenkins master pod gets scheduled (say after a restart) to a different node?

Will the PD "follow" the node?

Is there a case of the jenkins master pod being unable to find the PVC?

-- pkaramol
kubernetes
kubernetes-pod

1 Answer

4/26/2020

Will the [persistent disk] "follow" the node?

Yes. For volume types that can be dynamically attached to nodes, the storage provider will attach the volume to the node on which the corresponding pod is scheduled.

The other corollary to this for your application is that, if you use a newer Jenkins image in the deployment (and so delete and recreate the pod), if the new pod gets scheduled on a different node, the persistent disk can get moved.

(For this specific scenario you might find StatefulSets' handling of persistent volumes a little better than Deployments'; in the Helm chart you link to it sets the Deployment strategy: { type: Recreate } if persistence is enabled. This avoids a problem where the new pod can't be started until the old pod terminates and releases the PersistentVolumeClaim, but the old pod can't terminate until the new pod is up and running.)

-- David Maze
Source: StackOverflow