Windows Containers on windows and linux Kubernetes cluster

8/14/2018

I'm kind of new to the Kubernetes world. In my project we are planning to use windows containers(.net full framework) in short term and linux containers(.net core) for the long run.

We have a K8 cluster provided by infrastructure team and the cluster has mix of Linux and Windows nodes. I just wanted to know how my windows containers will only be deployed to windows nodes in the K8 cluster. Is it handled by K8 or Do I need anything else ?

-- marvelTracker
kubernetes
kubernetes-cluster
windows-container

2 Answers

8/14/2018

Below are the details from the Kubernetes Windows Documentation.

Because your cluster has both Linux and Windows nodes, you must explicitly set the nodeSelector constraint to be able to schedule pods to Windows nodes. You must set nodeSelector with the label beta.kubernetes.io/os to the value windows; see the following example:

apiVersion: v1
kind: Pod
metadata:
  name: iis
labels:
  name: iis
spec:
  containers:
    - name: iis
      image: microsoft/iis:windowsservercore-1709
      ports:
        - containerPort: 80
  nodeSelector:
    "beta.kubernetes.io/os": windows
-- Granville Schmidt
Source: StackOverflow

8/14/2018

You would need to add following lines to your YAML file. Details are available here https://kubernetes.io/docs/getting-started-guides/windows/

nodeSelector: "beta.kubernetes.io/os": windows

-- Gregory Suvalian
Source: StackOverflow