<p>I created a StatefulSet on GKE, and it provisioned a bunch of GCE disks that are attached to the pods that belong to that StatefulSet. Suppose I scale the StatefulSet to 0: the constituent pods are destroyed and the disks are released. When I scale back up, the disks are reattached and mounted inside the correct pods. </p>

<p>My questions are:</p>

<ul>
<li>How does Kubernetes keep track of which GCE disk to reconnect to which StatefulSet pod?</li>
<li>Suppose I want to restore a StatefulSet Pod's PV from a snapshot. How can I get Kubernetes to use the disk that was created from the snapshot, instead of old disk?</li>
</ul>

<p>When you scale the StatefulSet to 0 replicas, the pods get destroyed but the persistent volumes and persistent volume claims are kept. The association with the GCE disk is written inside the PersistentVolume object. When you scale the RS up again, pods are assigned to the correct PV and thus get the same volume from GCE.</p>

<p>In order to change the persistent volume - GCE disk association after a snapshot restore, you need to edit the PV object.</p>
