Member-only story
Kubernetes: Understanding Pod Affinity, Taint & Toleration
Hello readers, in one of my previous blogs on Kubernetes, we discussed Node Affinity and Node Selector and how they can be used to make pods scheduled on specific nodes. If you haven’t read it yet, I suggest going through it once to make things easier to understand and fill in the missing information.
In this blog, we will further discuss control over pod scheduling with the help of:
- Inter-pod affinity and anti-affinity.
- Taint and Toleration.
Prerequisite
You need a Kubernetes cluster if you want to follow along and be more hands-on.
Inter-pod affinity and anti-affinity
Just like node selectors and node affinity, pod definition uses labels assigned to nodes of the k8 cluster to decide which node that specific pod will land on.
Similarly, inter-pod affinity (or anti-affinity) is to be defined in the pod definition if you want to schedule (or avoid scheduling in case of anti-affinity) your pods on specific nodes. You can do it based on the labels of the pods already running/scheduled on the available cluster nodes.
Let us understand this with an example. Our initial setup has a cluster with two nodes (node01 and…
