Breaking

Tuesday, April 20, 2021

Kubernetes–Schedule a pod on a Linux node–Part 1

On our Kubernetes(AKS) cluster we have multiple node pools some with Linux nodes and some with Windows nodes:

But what if you want to schedule specific workloads on Linux or Windows nodes? The easiest way to control this is through the OS node selector. The OS node selector(“kubernetes.io/os”) is a built-in selector which indicates the OS that the node is running. We can use this selector to ensure that the pod is only deployed to nodes with the right OS.

Here is an example for Windows pods:

apiVersion: v1
kind: Pod
metadata:
name: WindowsApp
labels:
env: test
spec:
containers:
- name: WindowsApp
image: WindowsApp
imagePullPolicy: IfNotPresent
nodeSelector:
kubernetes.io/os: Windows
view raw WindowsApp.yaml hosted with ❤ by GitHub

And here is in example for Linux pods:

apiVersion: v1
kind: Pod
metadata:
name: LinuxApp
labels:
env: test
spec:
containers:
- name: LinuxApp
image: LinuxApp
imagePullPolicy: IfNotPresent
nodeSelector:
kubernetes.io/os: Linux
view raw LinuxApp.yaml hosted with ❤ by GitHub

Unfortunately you don’t always have direct control on the pod specification(e.g. when you are using a 3th party Helm chart). In that case we have to take a different approach. But that is for another blog post tomorrow…

No comments:

Post a Comment