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

3/13/2020

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?

-- NoƩ
amazon-web-services
availability-zone
kubernetes
volume

2 Answers

3/13/2020

You use the topology.kubernetes.io/zone label and node selectors for this kind of thing. However unless you're on a very old version of Kubernetes, this should be handled automatically by the scheduler.

-- coderanger
Source: StackOverflow

3/13/2020

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

-- mcfinnigan
Source: StackOverflow