kubernetesamazon-ekskubernetes-statefulset

Can a kubernetes pod from a statefulset move to a node in a different availability zone in case of an AZ unavailability?


Following SO question mentions that a pod in a statefulset which uses a persistent volume cannot move to a different availability zone on an availability zone failure, because the pod has affinity to the AZ through the persistent volume.

Kubernetes Stateful set, AZ and Volume claims: what happens when an AZ fails

If the pod didn't have a persistent volume attached, is it possible for the pod to move to a different AZ on an AZ unavailability?


Solution

  • a pod in a statefulset which uses a persistent volume cannot move to a different availability zone on an availability zone failure

    This is true in the most common configuration. But cloud providers now also provides block storage that are replicated to another AZ. So you might choose to use replicated block storage, for a larger cost and perhaps longer latency.

    is it possible for the pod to move to a different AZ on an AZ unavailability?

    You typically don't "move" pods in Kubernetes. But if a pod and node become unavailable, it can be recreated. If this happens on a different AZ or not, depends on how you have configured the pods. You typically don't want that it is recreated in a different AZ. You typically use a StatefulSet for a distributed application, to achieve high availability. You want it to tolerate that an AZ becomes unavailable, so it should spread it's instances among the AZ's. When an AZ that was unavailable becomes available again, you still want to tolerate that a AZ can go unavailable, so you cannot have all your instances in only two AZ's now.