We are running mongodb clusters with local persistent volumes using PSMDB. Because of these local volumes DBAs often view specific pods as being tied to specific physical nodes. We can manage this using the standard kubernetes statefuset affinity, nodeSelector and antiaffinity rules. However problems arise when doing maintenance tasks like moving or removing specific members.
Scenario 1 (moving a single member):
- We have a 3-member replicaset running on
Node-A(pod-0),Node-B(pod-1), andNode-C(pod-2). - We need to decommission
Node-A. - We want to move
pod-0to a newNode-D, triggering a replication sync on the new node, without outages or modifying the placement ofpod-1,pod-2.
Scenario 2 (node decommissioning):
- We have 5 member replicaset across 5 Nodes
- We need to remove specific nodes from the cluster (the node holding
pod-1and the node holdingpod-3). - Since StatefulSets scale down strictly by ordinal index (removing highest numbers first), we cannot simply “scale down” to remove these specific intermediate nodes.
Since the CR applies affinity rules to the entire StatefulSet, is there a recommended workflow to handle these situations?
As the operator uses standard kubernetes statefulsets affinity rules apply to all replicas uniformly.
Currently, our intended solution for the first one is to cordon the target nodes (Node-A), delete the specific pod (pod-0) and its local PVC. Is this the safest approach we could take, or does the operator expose a mechanism to pin specific members to specific nodes?
For scenario 2 we don’t see a way to do it without unnecessary shuffling of pods and doing replication multiple times.