Life's random bits By b1thunt3r (aka Ishan Jain)…
Assign Pods to Specific Nodes in Kubernetes

Assign Pods to Specific Nodes in Kubernetes

Ishan jain
Make sure kubernetes doesn't try to run Linux containers on Windows.

Azure Kubernetes Service (AKS) enables the deployment of clusters that support both Linux and Windows nodes simultaneously. However, Kubernetes itself does not inherently distinguish between Linux and Windows nodes; from its perspective, a node is simply a node.

To address this, Kubernetes offers the capability to assign labels to nodes, which can then be utilized through the nodeSelector feature. This allows specifying on which type of node (Linux or Windows) a particular pod should be scheduled to run.

Kubernetes

# partial pod.yaml
apiVersion: v1
kind: Pod
spec:
  nodeSelector:
    kubernetes.io/os: linux

Helm

Chart

# partial templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      {{- if .Values.nodeSelector }}
      nodeSelector: 
        {{- .Values.nodeSelector | toYaml | nindent 8 }}
      {{- end }}

Using values.yaml

# partial values.yaml
nodeSelector:
  kubernetes.io/os: linux

Using helm CLU

helm install . --set nodeSelector."kubernetes\\.io/os"=linux

Resources