diff --git a/README.md b/README.md index 7f76f1d926..b292b873bd 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ ToC: - [Using IRSA (IAM Roles for Service Accounts) in EKS](#using-irsa-iam-roles-for-service-accounts-in-eks) - [Software Installed in the Runner Image](#software-installed-in-the-runner-image) - [Using without cert-manager](#using-without-cert-manager) + - [Windows Runners](#setting-up-windows-runners) - [Multitenancy](#multitenancy) - [Troubleshooting](#troubleshooting) - [Contributing](#contributing) @@ -1764,6 +1765,118 @@ $ helm --upgrade install actions-runner-controller/actions-runner-controller \ admissionWebHooks.caBundle=${CA_BUNDLE} ``` +### Setting up Windows Runners + +The main two steps in enabling Windows self-hosted runners are: + +- Using `nodeSelector`'s property to filter the `cert-manger` and `actions-runner-controller` pods +- Deploying a RunnerDeployment using a Windows-based image + +For the first step, you need to set the `nodeSelector.kubernetes.io/os` property in both the `cert-manager` and the `actions-runner-controller` deployments to `linux` so that the pods for these two deployments are only scheduled in Linux nodes. You can do this as follows: + +```yaml +nodeSelector: + kubernetes.io/os: linux +``` + +`cert-manager` has 4 different application within it the main application, the `webhook`, the `cainjector` and the `startupapicheck`. In the parameters or values file you use for the deployment you need to add the `nodeSelector` property four times, one for each application. + +For the `actions-runner-controller` you only have to use the `nodeSelector` only for the main deployment, so it only has to be set once. + +Once this is set up, you will need to deploy two different `RunnerDeployment`'s, one for Windows and one for Linux. +The Linux deployment can use either the default image or a custom one, however, there isn't a default Windows image so for Windows deployments you will have to build your own image. + +Below we share an example of the YAML used to create the deployment for each Operating System and a Dockerfile for the Windows deployment. + +
Windows +

+ +#### RunnerDeployment + +```yaml +--- +apiVersion: actions.summerwind.dev/v1alpha1 +kind: RunnerDeployment +metadata: + name: k8s-runners-windows + namespace: actions-runner-system +spec: + template: + spec: + image: /: + dockerdWithinRunnerContainer: true + nodeSelector: + kubernetes.io/os: windows + kubernetes.io/arch: amd64 + repository: / + labels: + - windows + - X64 + - devops-managed +``` + +#### Dockerfile + +> Note that you'd need to patch the below Dockerfile if you need a graceful termination. +> See https://github.com/actions-runner-controller/actions-runner-controller/pull/1608/files#r917319574 for more information. + +```Dockerfile +FROM mcr.microsoft.com/windows/servercore:ltsc2019 + +WORKDIR /actions-runner + +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';$ProgressPreference='silentlyContinue';"] + +RUN Invoke-WebRequest -Uri https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip -OutFile actions-runner-win-x64-2.292.0.zip + +RUN if((Get-FileHash -Path actions-runner-win-x64-2.292.0.zip -Algorithm SHA256).Hash.ToUpper() -ne 'f27dae1413263e43f7416d719e0baf338c8d80a366fed849ecf5fffcec1e941f'.ToUpper()){ throw 'Computed checksum did not match' } + +RUN Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory('actions-runner-win-x64-2.292.0.zip', $PWD) + +RUN Invoke-WebRequest -Uri 'https://aka.ms/install-powershell.ps1' -OutFile install-powershell.ps1; ./install-powershell.ps1 -AddToPath + +RUN powershell Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + +RUN powershell choco install git.install --params "'/GitAndUnixToolsOnPath'" -y + +RUN powershell choco feature enable -n allowGlobalConfirmation + +CMD [ "pwsh", "-c", "./config.cmd --name $env:RUNNER_NAME --url https://github.com/$env:RUNNER_REPO --token $env:RUNNER_TOKEN --labels $env:RUNNER_LABELS --unattended --replace --ephemeral; ./run.cmd"] +``` +

+
+ + +
Linux +

+ +#### RunnerDeployment + +```yaml +--- +apiVersion: actions.summerwind.dev/v1alpha1 +kind: RunnerDeployment +metadata: + name: k8s-runners-linux + namespace: actions-runner-system +spec: + template: + spec: + image: /: + nodeSelector: + kubernetes.io/os: linux + kubernetes.io/arch: amd64 + repository: : + labels: + - linux + - X64 + - devops-managed +``` +

+
+ +After both `RunnerDeployment`'s are up and running, you can now proceed to deploy the `HorizontalRunnerAutoscaler` for each deployment. + ### Multitenancy > This feature requires controller version => [v0.26.0](https://github.com/actions-runner-controller/actions-runner-controller/releases/tag/v0.26.0)