0

I am creating a deployment that is going to use a GCE persistent disk to create a volume for the deployment's pod to use.

Since the pod is ephemeral, it may so happen that upon restarts, it ends up on a different node than the PD/PV/PVC.

In that case the following error may occur

Multi-Attach error for volume Volume is already exclusively attached

I am aware of this answer.

My question is whether there is a way of predictably / consistently collocating the pod that needs the volume and the PD on the same node so as to avoid restart delays.

pkaramol
  • 16,451
  • 43
  • 149
  • 324

1 Answers1

1

Add a label to the node that includes the name of the PVC or a common label used by the PV and PVC, you can then use node selector to ensure that the pod (or pods) always get scheduled to that node. This is not the most scalable method and also not very resilient because you'll have a single point of failure.

You may also want to consider using StatefulSets since those can include a PersistentVolumeTemplate which will provision the PVC (which will dynamically provision the PV). The StatefulSet will also try to keep a pod on the same node to maintain state.

Patrick W
  • 4,603
  • 1
  • 12
  • 26