amazon-web-serviceskubernetesvolumeavailability-zone

Kubernetes: specify or determine pod availability zone in an aws cluster


I would like to mount an amazon ebs volume (with data on it) to my pod. The problem is that I didn't find a way to determine in advance the availability zone of the pod before starting it. If the pod doesn't start on the same availability zone of the volume, it leads to a binding error.

How can I specify or determine the availability zone of a pod before starting it?


Solution

  • I'm not sure it's possible to determine ahead of time where a pod is going to be scheduled.

    What you can do is set node affinity on your deployments so that they always deploy to nodes with certain labels.

    For e.g, if you label your nodes with their az, then use node affinity to assign your pods to those nodes, you should accomplish what you're trying to do.

    https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#node-affinity