简体   繁体   中英

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?

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.

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 eg, 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM