Kubernetes jobs for different OS

5/29/2019

With the support of Windows server 2019 in Kubernetes 1.14 it seems possible to have nodes of different OS. For example a Ubuntu 18.04 Node, RHEL 7 Node, Windows Server Node within one cluster.

In my use case I would like to have pre-configured queue system with a queue per OS type. The nodes would feed off their specific queues processing the job.

With the above in my mind is it possible to configure a Job to go to a specific queue and in turn a specific OS node?

-- Softey
kubernetes

1 Answer

5/29/2019

Kubernetes nodes come populated with a standard set of labels, this includes kubernetes.io/os

Pods can then be assigned to certain places via a nodeSelector, podAffinity and podAntiAffinity.

apiVersion: extensions/v1beta1
kind: Pod
metadata:
  name: anapp
spec:
  containers:
  - image: docker.io/me/anapp
    name: anapp
    ports:
     - containerPort: 8080
  nodeSelector:
    kubernetes.io/os: linux

If you need finer grained control (for example choosing between Ubuntu/RHEL) you will need to add custom labels in your kubernetes node deployment to select from. This level of selection is rare as container runtimes try and hide most of the differences from you, but if you have a particular case then add extra label metadata to the nodes.

I would recommend using the ID and VERSION_ID fields from cat /etc/*release* as most Linux distros populate this information in some form.

kubectl label node thenode softey.com/release-id=debian
kubectl label node thenode softey.com/release-version-id=9
-- Matt
Source: StackOverflow