Affinity and Antiaffinity in Kubernetes simplified

Studying Affinity and AntiAffinity can be challenging due to the length of the official documentation. This post is not intended to replace the official docs but to provide a bird’s-eye view of the structure.

Some takeaways:

  • affinity is a sub section of pod’s spec
  • The diagram as follow:
pod affinity simple diagram
pod affinity simple diagram

  • The full diagram as follow:
pod affinity diagram full size
Pod affinity full diagram

Please ignore the root node (green). I don’t know how to remove it in Xmind.

The diagram looks complicated. However, if you look closely, there is a lot of duplication. For example, the block with key, operator, values appears many times.

The operator can be one of the following values:

key and values are string and array of string accordingly.

You can always refer to the official documentation here for examples.

Leave a Comment