Search code examples
kuberneteskubernetes-statefulsetkubernetes-pvc

Safely unbind statefulset/my-pod-0 pvc without affecting the other replicas


I have a statefulset with 2 pods, running on separate dedicated nodes, each with its own pvc.

I need to perform some maintenance to the PVs assigned to each of the PVCs assigned to the statefulset's pods.

So far I've been able to scale down the statefulset to 1 replica, which brought offline statefulset/pod-1, this way I've been able to perform the maintenance task.

Now I need to perform the same task to statefulset/pod-0, without taking offline statefulset/pod-1.

What are my options? Remember, statefulset/pod-0's pv must be unmounted in order to start the maintenance task.


Solution

  • I was able to perform the task on statefulset/pod-0 by:

    • Cordon the node
    • Delete statefulset/pod-0

    Once the task was complete uncordon the node and the pod started automatically without any issues.

    This will only work if the pod contains a specific nodeAffinity