Run Windows builds in a Kubernetes build infrastructure
You can run Windows builds in your Kubernetes build infrastructure. Windows Server 2019 images are available for running CI Builds and for out-of-the-box CI steps such as Run, Save, and Restore.
Build and Push an image to Docker Registry, Build and Push to ECR, and Build and Push to GCR steps are not supported with Windows builds on Kubernetes build infrastructure.
Privileged mode is required for Docker-in-Docker. If your build process needs to run Docker commands, Docker-in-Docker (DinD) with privileged mode is necessary when using a Kubernetes cluster build infrastructure; however, Windows doesn't support privileged mode. If you need to run Docker commands, you'll need to use another build infrastructure, such as Harness Cloud or a VM build infrastructure, where you can run Docker commands directly on the host.
Only Windows Server 2019 images are supported. If you are using Google Kubernetes Engine, make sure you use the recommended image type for Windows Server 2019.
Configure cluster and build infrastructure
Set up your cluster with both Linux and Windows node pools. Linux is required for running the Delegate.
Install the Delegate on the Linux node pool by specifying the Linux node pool selector. For example, on GKE the Linux node pool label is
kubernetes.io/os: linuxand the Windows node pool label is
kubernetes.io/os: windows. The selectors are automatically set up on the nodes.
In your pipeline's Build stage, go to the Infrastructure tab and configure the following settings:
- Select Windows for the OS.
- Expand the Advanced section, and add a Node Selector to use the Windows node pool. Enter
kubernetes.io/osas the Key and
windowsas the Value.
Save and run your pipeline.
If you use a custom Windows image in a Run step, the container must be based on Windows Server Core version 1809 and must include
netapi32.dll. To include this in your image, add the following command to the Dockerfile:
COPY --from=core /windows/system32/netapi32.dll /windows/system32/netapi32.dll
Pipelines-as-code YAML example
Here is an example of a pipeline that runs a Windows build on a Kubernetes cluster build infrastructure. Not the presence of
nodeSelector in the
stage: spec: infrastructure: spec:.
name: Build and Test
command: "Write-Host \"hello world\" "