My Understanding of Taints, Toleration, and Node Affinity from Kubernetes
As of 16th October 2022, We have Kubernetes Version 1.25.2 and It follows X.Y.Z versioning where X is the major, Y is the Minor and Z is the Patch version. From 2014 to now, It has grown so much that we all might agree that this Software is one of a kind.
I am not here to talk about its maturity and usefulness or similar. I have first been introduced to this tool back in 2015 as it was an Alpha version back then which made me hate my life a lot of time configuring and managing self-configured clusters. I should not feel low by accepting that I still have very little knowledge about this tool and practices related to Kubernetes. But over the years I tried to make it work for me and simplified my understanding. From version 1.6, Taints, Toleration, and Node Affinity got extra focus as they got a promotion to Beta. Let me share my thoughts about them.
To understand them, I took an example of a typical home’s furniture use case.
Assume, I have these three pieces of furniture in my home.
And my wife has some rules to follow when using them.
- The cupboard should be used only for kitchen items.
- The Wardrobe is primarily for special clothes where we do have a hanging solution.
- The closet is about other clothes, shoes, etc items to keep.
In her opinion, If We do not abide by those rules, It will destroy tranquility. 🙂
Let us assume that these rules are categorized into 3.
- Taint
- Toleration
- Affinity
To match these rules with the furniture, assume that some rules are applied to the furniture and some are to the things we keep on the furniture.
- Taint:
- These rules are applicable to the furniture. i.e. Some kind of identity matching like a portion of the furniture is marked in some way.
- Tainting works with Toleration.
- Taint is the counterpart of Toleration.
- Toleration:
- These rules are applicable to the items or things. i.e. Some kind of identity matching with the furniture where it is expected.
- Toleration is the counterpart of Taint.
- Affinity:
- This is not directly connected with the first two categories.
- These rules are workable with the object’s properties.
- It works with some conditions or matching of certain tags. i.e I have some shoes but one of them is a bit special and I want to keep it always in my wardrobe’s special section, not the closet with other shoes or not with clothes.
Enough with this symbolic representation. I guess you have got a basic idea of what are they.