Run hybrid workloads in Kubernetes¶
To run Windows workloads in a hybrid Windows Kubernetes cluster, you must target your workloads to nodes that are running the correct Windows version. Failure to correctly target your workloads may result in an error when Kubernetes schedules the Pod on an incompatible node:
Error response from daemon: hcsshim::CreateComputeSystem win2019-deployment-no-nodeselect: The container operating system does not match the host operating system.
Note the Windows version associated with each of the nodes in your cluster:
kubectl get node
Example output:
NAME STATUS ROLES AGE VERSION manager-node Ready master 51m v1.23.4-mirantis-1 win2019-node Ready <none> 44m v1.23.4 win2022-node Ready <none> 38m v1.23.4
Create a deployment with the appropriate node selectors. Use
10.0.17763
for Windows Server 2019 workloads and10.0.20348
for Windows Server 2022 workloads.For example purposes, paste the following content into a file called
win2019-deployment.yaml
:apiVersion: apps/v1 kind: Deployment metadata: labels: app: win2019-deployment name: win2019-deployment spec: replicas: 5 selector: matchLabels: app: win2019-deployment template: metadata: labels: app: win2019-deployment name: win2019-deployment spec: containers: - name: win2019-deployment image: mcr.microsoft.com/windows/nanoserver:1809 command: ["cmd", "/c", "ping -t localhost"] ports: - containerPort: 80 nodeSelector: kubernetes.io/os: windows node.kubernetes.io/windows-build: 10.0.17763
Apply the deployment:
kubectl apply -f win2019-deployment.yaml
Verify that the Pods are scheduled on the required node:
kubectl get pods -o wide
Example output:
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES win2019-deployment-57d75f6f9f-ldsqf 1/1 Running 0 6m39s 192.168.50.76 win2019-node <none> <none> win2019-deployment-57d75f6f9f-n5b25 1/1 Running 0 6m39s 192.168.50.79 win2019-node <none> <none> win2019-deployment-57d75f6f9f-r5mz6 1/1 Running 0 6m39s 192.168.50.78 win2019-node <none> <none> win2019-deployment-57d75f6f9f-xggmt 1/1 Running 0 6m39s 192.168.50.77 win2019-node <none> <none> win2019-deployment-57d75f6f9f-zltk2 1/1 Running 0 7m7s 192.168.50.73 win2019-node <none> <none>