Merge pull request #189 from google/win
Update docs and script for installing win machines
This commit is contained in:
commit
d2b981a07e
7 changed files with 227 additions and 188 deletions
|
@ -1,14 +1,8 @@
|
||||||
# escape=`
|
# escape=`
|
||||||
|
|
||||||
# use windows server core image
|
# use windows server core image
|
||||||
ARG agent_windows_version
|
ARG agent_windows_version=latest
|
||||||
FROM gcr.io/llvm-premerge-checks/agent-windows:${agent_windows_version}
|
FROM gcr.io/llvm-premerge-checks/agent-windows-vs2019:${agent_windows_version}
|
||||||
|
|
||||||
# install buildkite agent as described in the documentation
|
COPY start_agent.ps1 C:\scripts\
|
||||||
# https://buildkite.com/docs/agent/v3/windows
|
|
||||||
# Supply your agent token via the arguement "-token <mytoken" when building the image
|
|
||||||
ARG token
|
|
||||||
ENV BUILDKITE_BUILD_PATH=C:\ws\bk
|
|
||||||
|
|
||||||
COPY start_agent.ps1 C:\scripts\
|
|
||||||
CMD "powershell C:\scripts\start_agent.ps1"
|
CMD "powershell C:\scripts\start_agent.ps1"
|
|
@ -1,9 +1,4 @@
|
||||||
$Env:buildkiteAgentToken = [IO.File]::ReadAllText("C:\credentials\buildkite-token.txt")
|
c:\credentials\buildkite-env.ps1
|
||||||
|
# Install Buildkite agent.
|
||||||
#Set-ExecutionPolicy Bypass -Scope Process -Force
|
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/buildkite/agent/master/install.ps1'))
|
||||||
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/buildkite/agent/master/install.ps1'))
|
C:\buildkite-agent\bin\buildkite-agent.exe start
|
||||||
|
|
||||||
# use the name of the host machine as name for the agent in buildkite
|
|
||||||
$env:BUILDKITE_AGENT_NAME="win-vs17 $env:PARENT_HOSTNAME"
|
|
||||||
|
|
||||||
C:\buildkite-agent\bin\buildkite-agent.exe start --tags "os=windows"
|
|
|
@ -62,54 +62,49 @@ These are the steps to set up the build server on a clean infrastructure:
|
||||||
|
|
||||||
## Creating docker containers on Windows
|
## Creating docker containers on Windows
|
||||||
|
|
||||||
If you want to build/update/test docker container for Windows, you need to do this on a Windows machine. Here are the instructions to set up such a machine on GCP.
|
If you want to build/update/test docker container for Windows, you need to do this on a Windows machine.
|
||||||
|
|
||||||
|
**Note**: There is an existing *windows-development* machine that you can resume and use for development. Please stop it after use.
|
||||||
|
|
||||||
|
Here are the instructions to set up such a machine on GCP.
|
||||||
|
|
||||||
1. Pick a GCP Windows image with Desktop Support.
|
1. Pick a GCP Windows image with Desktop Support.
|
||||||
* pick a "persistent SSD" as boot Disk. This is much faster
|
* pick a "persistent SSD" as boot Disk. This is much faster
|
||||||
* Add a "local scratch SSD" and use it as you workspace. This is much faster.
|
* (optionally) add a "local scratch SSD" and use it as you workspace. This will make builds faster, but you **will not be able to stop** this instance and will have to kill and re-create it again.
|
||||||
|
* make sure that you give enough permissions in "Identity and API access" to be able to e.g. push new docker images to GCR.
|
||||||
|
|
||||||
1. Format the local SSD partition and use it as workspace.
|
1. Format the local SSD partition and use it as workspace.
|
||||||
1. install [Chocolately](https://chocolatey.org/docs/installation):
|
1. install [Chocolately](https://chocolatey.org/docs/installation):
|
||||||
```bat
|
```powershell
|
||||||
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
|
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
|
||||||
```
|
```
|
||||||
1. Install git: `choco install -y git`
|
1. Install development tools: `choco install -y git googlechrome vscode`
|
||||||
|
1. (optionally) If you want to be able to push changes to github, you need to set up your github SSH keys and user name:
|
||||||
|
```powershell
|
||||||
|
ssh-keygen
|
||||||
|
git config --global user.name <your name>
|
||||||
|
git config --global user.email <your email>
|
||||||
|
```
|
||||||
1. Install [Docker Enterprise](https://docs.docker.com/ee/docker-ee/windows/docker-ee/) and reboot:
|
1. Install [Docker Enterprise](https://docs.docker.com/ee/docker-ee/windows/docker-ee/) and reboot:
|
||||||
```powershell
|
```powershell
|
||||||
Install-Module DockerMsftProvider -Force
|
Install-Module DockerMsftProvider -Force
|
||||||
Install-Package Docker -ProviderName DockerMsftProvider -Force
|
Install-Package Docker -ProviderName DockerMsftProvider -Force
|
||||||
Restart-Computer
|
Restart-Computer
|
||||||
```
|
```
|
||||||
1. *optional:* install apps to help you work in the machine:
|
|
||||||
```powershell
|
|
||||||
choco install -y googlechrome vscode
|
|
||||||
```
|
|
||||||
1. Log out of the machine and log back in.
|
|
||||||
1. Repeat until success:
|
|
||||||
1. Start "Docker Desktop" and let it install it's dependencies.
|
|
||||||
Then reboot manually, when the error message pops up.
|
|
||||||
1. If you have trouble with the machine name: try to shorten it to 16 chars.
|
|
||||||
1. Configure the Docker credentials for GCP:
|
1. Configure the Docker credentials for GCP:
|
||||||
```powershell
|
```powershell
|
||||||
gcloud components install docker-credential-gcr
|
gcloud init # set options according to ./k8s_config here
|
||||||
docker-credential-gcr configure-docker
|
gcloud components install docker-credential-gcr
|
||||||
```
|
docker-credential-gcr configure-docker
|
||||||
|
```
|
||||||
1. To build and run the current agent run:
|
1. To build and run the current agent run:
|
||||||
```powershell
|
```powershell
|
||||||
git clone https://github.com/google/llvm-premerge-checks
|
cd c:\
|
||||||
cd llvm-premerge-checks\containers
|
git clone https://github.com/google/llvm-premerge-checks
|
||||||
powershell .\build_run.ps1 agent-windows-jenkins
|
cd llvm-premerge-checks\containers
|
||||||
```
|
.\build_deploy.ps1 agent-windows-buildkite # or agent-windows-jenkins
|
||||||
1. If you want to be able to push changes to github, you need to set up your github SSH keys and user name:
|
c:\llvm-premerge-check\scripts\windows_agent_start_buildkite.ps1 # or windows_agent_start_jenkins.ps1
|
||||||
```powershell
|
```
|
||||||
ssh-keygen
|
|
||||||
git config --global user.name <your name>
|
|
||||||
git config --global user.email <your email>
|
|
||||||
```
|
|
||||||
|
|
||||||
To push push a new container run in `containers`:
|
|
||||||
```powershell
|
|
||||||
powershell .\build_deploy.ps1 <container-folder>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Spawning a new windows agent
|
## Spawning a new windows agent
|
||||||
|
|
||||||
|
@ -118,20 +113,21 @@ To spawn a new windows agent:
|
||||||
1. Go to the [GCP page](https://pantheon.corp.google.com/compute/instances?project=llvm-premerge-checks&instancessize=50) and pick a new number for the agent.
|
1. Go to the [GCP page](https://pantheon.corp.google.com/compute/instances?project=llvm-premerge-checks&instancessize=50) and pick a new number for the agent.
|
||||||
1. Run `kubernetes/windows_agent_create.sh agent-windows-<number>`
|
1. Run `kubernetes/windows_agent_create.sh agent-windows-<number>`
|
||||||
1. Go to the [GCP page](https://pantheon.corp.google.com/compute/instances?project=llvm-premerge-checks&instancessize=50) again
|
1. Go to the [GCP page](https://pantheon.corp.google.com/compute/instances?project=llvm-premerge-checks&instancessize=50) again
|
||||||
1. login to the new machine via RDP (you probably need to set the i).
|
1. login to the new machine via RDP (you will need a RDP client, e.g. Chrome app).
|
||||||
1. In the RDP session: run these commands in the CMD window to bootstrap the Windows machine:
|
1. In the RDP session: run these commands in the CMD window under Administrator to bootstrap the Windows machine:
|
||||||
```powershell
|
```powershell
|
||||||
Invoke-WebRequest -uri 'https://raw.githubusercontent.com/google/llvm-premerge-checks/master/scripts/windows_agent_bootstrap.ps1' -OutFile windows_agent_bootstrap.ps1
|
Invoke-WebRequest -uri 'https://raw.githubusercontent.com/google/llvm-premerge-checks/master/scripts/windows_agent_bootstrap.ps1' -OutFile windows_agent_bootstrap.ps1
|
||||||
.\windows_agent_bootstrap.ps1
|
./windows_agent_bootstrap.ps1
|
||||||
```
|
```
|
||||||
1. Ignore the pop-up to format the new disk.
|
Ignore the pop-up to format the new disk andw wait for the machine to reboot.
|
||||||
1. Wait for the machine to reboot, then copy the credendials from `windows-agent-2` in `c:\credentials` to the new machine to `c:\credentials`. You can do that by mounting a folder of your host machine via RDP into the Windows VMs.
|
1. Create `c:\credentials` folder with the agent credentials:
|
||||||
1: Copy the credientals to `C:\credentials` from another Windows agent.
|
For *Buildkite* add file `buildkite-env.ps1`:
|
||||||
1. Run this script to start the container:
|
```powershell
|
||||||
```powershell
|
$Env:buildkiteAgentToken = "secret-token"
|
||||||
Invoke-WebRequest -uri 'https://raw.githubusercontent.com/google/llvm-premerge-checks/master/scripts/windows_agent_start.ps1' -OutFile windows_agent_start.ps1
|
$Env:BUILDKITE_AGENT_TAGS = "queue=premerge;os=windows"
|
||||||
.\windows_agent_start.ps1 jenkins
|
```
|
||||||
```
|
For *Jenkins*: `build-agent-results_key.json` to access cloud storage copy from one of the existing machines.
|
||||||
|
1. Start the container `C:\llvm-premerge-checks\scripts\windows_agent_start_[buildkite|jenkins].ps1 `
|
||||||
|
|
||||||
## Testing scripts locally
|
## Testing scripts locally
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,6 @@ gcloud beta compute instances create "${NAME}" \
|
||||||
--zone="${GCP_ZONE}" \
|
--zone="${GCP_ZONE}" \
|
||||||
--machine-type=n1-standard-16 \
|
--machine-type=n1-standard-16 \
|
||||||
--local-ssd=device-name=local-ssd-0 \
|
--local-ssd=device-name=local-ssd-0 \
|
||||||
--image=windows-server-2019-dc-v20191210 \
|
--image=windows-server-2019-dc-for-containers-v20200512 \
|
||||||
--image-project=windows-cloud \
|
--image-project=windows-cloud \
|
||||||
--boot-disk-size=100GB
|
--boot-disk-size=100GB
|
||||||
|
|
|
@ -1,54 +1,57 @@
|
||||||
# Copyright 2019 Google LLC
|
# Copyright 2019 Google LLC
|
||||||
|
|
||||||
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
|
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
# You may obtain a copy of the License at
|
# You may obtain a copy of the License at
|
||||||
|
|
||||||
# https://llvm.org/LICENSE.txt
|
# https://llvm.org/LICENSE.txt
|
||||||
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
# 1st stage of the installation process.
|
# 1st stage of the installation process.
|
||||||
# This script only needs to be run once per machine.
|
# This script only needs to be run once per machine.
|
||||||
|
|
||||||
Write-Host "Initializing local SSD..."
|
Write-Host "Initializing local SSD..."
|
||||||
New-Variable -Name diskid -Value (Get-Disk -FriendlyName "Google EphemeralDisk").Number
|
New-Variable -Name diskid -Value (Get-Disk -FriendlyName "Google EphemeralDisk").Number
|
||||||
#New-Variable -Name diskid -Value (Get-Disk -FriendlyName "NVMe nvme_card").Number
|
#New-Variable -Name diskid -Value (Get-Disk -FriendlyName "NVMe nvme_card").Number
|
||||||
|
|
||||||
# TODO: check if machine has an SSD
|
# TODO: check if machine has an SSD
|
||||||
# TODO: only do this, if SSD is not yet partioned and formatted
|
# TODO: only do this, if SSD is not yet partioned and formatted
|
||||||
Initialize-Disk -Number $diskid
|
Initialize-Disk -Number $diskid
|
||||||
New-Partition -DiskNumber $diskid -UseMaximumSize -AssignDriveLetter
|
New-Partition -DiskNumber $diskid -UseMaximumSize -AssignDriveLetter
|
||||||
Format-Volume -DriveLetter D
|
Format-Volume -DriveLetter D
|
||||||
|
|
||||||
Write-Host "install chocolately as package manager..."
|
Write-Host "install chocolately as package manager..."
|
||||||
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
|
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
|
||||||
choco feature disable --name showDownloadProgress
|
choco feature disable --name showDownloadProgress
|
||||||
choco install -y git
|
choco install -y git
|
||||||
|
|
||||||
# move docker folder to SSD to get better IO performance
|
# move docker folder to SSD to get better IO performance
|
||||||
New-Item -Path "D:\" -Name "Docker" -ItemType "directory"
|
New-Item -Path "D:\" -Name "Docker" -ItemType "directory"
|
||||||
cmd /C "mklink /j C:\ProgramData\Docker D:\docker"
|
cmd /C "mklink /j C:\ProgramData\Docker D:\docker"
|
||||||
|
|
||||||
# create folder for credentials
|
# create folder for credentials
|
||||||
New-Item -Path "C:\" -Name "credentials" -ItemType "directory"
|
New-Item -Path "C:\" -Name "credentials" -ItemType "directory"
|
||||||
|
|
||||||
# install Docker
|
# install Docker
|
||||||
Install-PackageProvider -Name NuGet -Force
|
Install-PackageProvider -Name NuGet -Force
|
||||||
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
|
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
|
||||||
Install-Package -Name docker -ProviderName DockerMsftProvider -Force
|
Install-Package -Name docker -ProviderName DockerMsftProvider -Force
|
||||||
sc.exe config docker start=delayed-auto
|
sc.exe config docker start=delayed-auto
|
||||||
|
|
||||||
# install gcloud and authenticate access to gcr.io registry
|
# install gcloud and authenticate access to gcr.io registry
|
||||||
# TODO: find a better way to install the Google Cloud SDK, avoid ingoring the checksum
|
# TODO: find a better way to install the Google Cloud SDK, avoid ingoring the checksum
|
||||||
choco install -y gcloudsdk --ignore-checksums
|
choco install -y gcloudsdk --ignore-checksums
|
||||||
|
|
||||||
# exclude drive d from Virus scans, to get better performance
|
# exclude drive d from Virus scans, to get better performance
|
||||||
Add-MpPreference -ExclusionPath “D:\”
|
Add-MpPreference -ExclusionPath “D:\”
|
||||||
|
|
||||||
# Reboot
|
# clone scripts repo (this one)
|
||||||
Restart-Computer -Force
|
git clone https://github.com/google/llvm-premerge-checks.git "c:\llvm-premerge-checks"
|
||||||
|
|
||||||
|
# Reboot
|
||||||
|
Restart-Computer -Force
|
||||||
|
|
55
scripts/windows_agent_start_buildkite.ps1
Normal file
55
scripts/windows_agent_start_buildkite.ps1
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
# Copyright 2019 Google LLC
|
||||||
|
|
||||||
|
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
|
||||||
|
# https://llvm.org/LICENSE.txt
|
||||||
|
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# Pull and start the Docker container for a Windows agent.
|
||||||
|
# To setup a Windows agent see docs/playbooks.md
|
||||||
|
|
||||||
|
param(
|
||||||
|
[string]$version = "latest",
|
||||||
|
[switch]$testing = $false
|
||||||
|
)
|
||||||
|
|
||||||
|
$NAME="agent-windows-buildkite"
|
||||||
|
$IMAGE="gcr.io/llvm-premerge-checks/${NAME}:${version}"
|
||||||
|
|
||||||
|
Write-Output "Authenticating docker..."
|
||||||
|
Write-Output "y`n" | gcloud auth configure-docker
|
||||||
|
|
||||||
|
Write-Output "Pulling new image..."
|
||||||
|
docker pull ${IMAGE}
|
||||||
|
|
||||||
|
Write-Output "Stopping old container..."
|
||||||
|
docker stop ${NAME}
|
||||||
|
docker rm ${NAME}
|
||||||
|
|
||||||
|
Write-Output "Starting container..."
|
||||||
|
if (${testing}) {
|
||||||
|
docker run -it `
|
||||||
|
-v D:\:C:\ws `
|
||||||
|
-v C:\credentials:C:\credentials `
|
||||||
|
-e BUILDKITE_AGENT_NAME=$env:computername `
|
||||||
|
-e BUILDKITE_BUILD_PATH=C:\ws `
|
||||||
|
--restart unless-stopped `
|
||||||
|
--name ${NAME} `
|
||||||
|
${IMAGE} powershell
|
||||||
|
} else {
|
||||||
|
docker run -d `
|
||||||
|
-v D:\:C:\ws `
|
||||||
|
-v C:\credentials:C:\credentials `
|
||||||
|
-e BUILDKITE_AGENT_NAME=$env:computername `
|
||||||
|
-e BUILDKITE_BUILD_PATH=C:\ws `
|
||||||
|
--restart unless-stopped `
|
||||||
|
--name ${NAME} `
|
||||||
|
${IMAGE}
|
||||||
|
}
|
|
@ -1,57 +1,53 @@
|
||||||
# Copyright 2019 Google LLC
|
# Copyright 2019 Google LLC
|
||||||
|
|
||||||
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
|
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
# You may obtain a copy of the License at
|
# You may obtain a copy of the License at
|
||||||
|
|
||||||
# https://llvm.org/LICENSE.txt
|
# https://llvm.org/LICENSE.txt
|
||||||
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
# Pull and start the Docker container for a Windows agent.
|
# Pull and start the Docker container for a Windows agent.
|
||||||
# To setup a Windows agent see docs/playbooks.md
|
# To setup a Windows agent see docs/playbooks.md
|
||||||
|
|
||||||
# TODO: add parameter to bootstrap buildkite or jenkins
|
param(
|
||||||
|
[string]$version = "latest",
|
||||||
param(
|
[switch]$testing = $false
|
||||||
[Parameter(Mandatory=$true)]
|
)
|
||||||
[ValidateSet("buildkite", "jenkins")]
|
|
||||||
[string]$master,
|
$NAME="agent-windows-jenkins"
|
||||||
[switch]$testing = $false
|
$IMAGE="gcr.io/llvm-premerge-checks/${NAME}:${version}"
|
||||||
)
|
|
||||||
|
Write-Output "Authenticating docker..."
|
||||||
$NAME="agent-windows-${master}"
|
Write-Output "y`n" | gcloud auth configure-docker
|
||||||
$IMAGE="gcr.io/llvm-premerge-checks/${NAME}"
|
|
||||||
|
Write-Output "Pulling new image..."
|
||||||
Write-Output "Authenticating docker..."
|
docker pull ${IMAGE}
|
||||||
Write-Output "y`n" | gcloud auth configure-docker
|
|
||||||
|
Write-Output "Stopping old container..."
|
||||||
Write-Output "Pulling new image..."
|
docker stop ${NAME}
|
||||||
docker pull ${IMAGE}
|
docker rm ${NAME}
|
||||||
|
|
||||||
Write-Output "Stopping old container..."
|
Write-Output "Starting container..."
|
||||||
docker stop ${NAME}
|
if (${testing}) {
|
||||||
docker rm ${NAME}
|
docker run -it `
|
||||||
|
-v D:\:C:\ws `
|
||||||
Write-Output "Starting container..."
|
-v C:\credentials:C:\credentials `
|
||||||
if (${testing}) {
|
-e PARENT_HOSTNAME=$env:computername `
|
||||||
docker run -it `
|
--restart unless-stopped `
|
||||||
-v D:\:C:\ws `
|
--name ${NAME} `
|
||||||
-v C:\credentials:C:\credentials `
|
${IMAGE} powershell
|
||||||
-e PARENT_HOSTNAME=$env:computername `
|
} else {
|
||||||
--restart unless-stopped `
|
docker run -d `
|
||||||
--name ${NAME} `
|
-v D:\:C:\ws `
|
||||||
${IMAGE} powershell
|
-v C:\credentials:C:\credentials `
|
||||||
} else {
|
-e PARENT_HOSTNAME=$env:computername `
|
||||||
docker run -d `
|
--restart unless-stopped `
|
||||||
-v D:\:C:\ws `
|
--name ${NAME} `
|
||||||
-v C:\credentials:C:\credentials `
|
${IMAGE}
|
||||||
-e PARENT_HOSTNAME=$env:computername `
|
}
|
||||||
--restart unless-stopped `
|
|
||||||
--name ${NAME} `
|
|
||||||
${IMAGE}
|
|
||||||
}
|
|
Loading…
Reference in a new issue