Yesterday I blogged about the usage of the “kubernetes.io/os” nodeselector to schedule a pod specifically on a windows or linux node pool.
Today I want to share another way through the usage of taints and tolerations.
This Kubernetes feature allows users to mark a node (taint the node) so that no pods can be scheduled to it, unless a pod has a toleration that indicates it will accept this taint. Using this Kubernetes feature we can create nodes that are reserved (dedicated) for specific pods. Using this, we can pick one OS and taint all the nodes with this OS, so that any pods that do not specify toleration will use the non-tainted nodes. This Taint effectively allows us to specify a default OS for the cluster, and if you want to use the other OS, you need to state this explicitly.
To enable this, we first need to taint our Windows nodes. We would run this command for each Windows node:
kubectl taint nodes <nodeName> OS=Windows:NoSchedule
After this is applied it will prevent any pods that do not tolerate that condition from running on that node.
Now we need to update our pod spec for our Windows app to tolerate this.
If no toleration is specified, the pod will default to running on the Linux nodes.
More information: https://docs.microsoft.com/en-us/azure-stack/aks-hci/adapt-apps-mixed-os-clusters