Skip to main content

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.

Important Notes

  • 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

  1. Set up your cluster with both Linux and Windows node pools. Linux is required for running the Delegate.

  2. 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 linux and the Windows node pool label is windows. The selectors are automatically set up on the nodes.

  3. In your pipeline's Build stage, go to the Infrastructure tab and configure the following settings:

    1. Select Windows for the OS.
    2. Expand the Advanced section, and add a Node Selector to use the Windows node pool. Enter as the Key and windows as the Value.

  4. 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 os and nodeSelector in the stage: spec: infrastructure: spec:.

name: WindowsK8
identifier: WindowsK8
projectIdentifier: myproject
orgIdentifier: default
tags: {}
repoName: testing-flask-with-pytest
build: <+input>
- stage:
name: Build and Test
identifier: Build_and_Test
type: CI
cloneCodebase: true
type: KubernetesDirect
connectorRef: $K8S_CONNECTOR
namespace: harness-delegate-ng
automountServiceAccountToken: true
nodeSelector: windows
os: Windows
- step:
type: Run
name: helloWorld
identifier: Pre
image: winamd64/python
shell: Powershell
command: "Write-Host \"hello world\" "