How to have an annotation only in one pod of a given deployment?

Viewed 274

Imagine you have a Kubernetes deployment in a cluster with autoscaling capabilities.

I want to make sure that only of the pods from this deployment contains a specific annotation.

It could be for example the first running pod, and when it stops working this annotation would be replicated to a different pod.

1 Answers

If you really want to prevent downtime while some nodes are going down annotations is probably not the best way. You can use a combination of some of these.

  • Pod Topology Spread Constraints. For example, make sure there is always a pod running in one of the availability zones. Or on a node that never goes down.
  • Pod Disruption Budget (mentioned in the comments above). For example, make sure that you always have a minimum set of unavailable pods. For example, don't allow the cluster autoscaler to drain the node unless another pod is up somewhere else.

✌️

Related