Skip to content

Commit

Permalink
Gangams/ws2022 support (#756)
Browse files Browse the repository at this point in the history
* use hyperv isolation

* multi-arc image support

* multi-arc image support

* multi-arc image support

* multi-arc image support

* multi-arc image support

* multi-arc image support

* multi-arc image support

* multi-arc image support

* multi-arc image support

* multi-arc image support

* doc and script updates

* add common as dependency for multi-arc job

* merge into single job for perf evaluation

* merge into single job for perf evaluation

* merge into single job for perf evaluation

* separate jobs for ltsc2019 & ltsc2022

* separate jobs for ltsc2019 & ltsc2022

* update dev image docker file & script

* remove unnecessary task

* update prod pipeline yaml for windows multi-arc image

* test yamls for ltsc2019 & ltsc2022

* fix pr checker fail

* fix repoImageWindows path in windows pipeline

* remove passing imagetag for prod
  • Loading branch information
ganga1980 authored May 9, 2022
1 parent 52c7fe4 commit 0da25a7
Show file tree
Hide file tree
Showing 12 changed files with 486 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
run: cd ./build/windows/ && & .\Makefile.ps1
- name: Create-docker-image
run: |
cd ./kubernetes/windows/ && docker build . --file Dockerfile -t $env:IMAGETAG --build-arg IMAGE_TAG=$env:IMAGETAG_TELEMETRY
cd ./kubernetes/windows/ && docker build . --file Dockerfile -t $env:IMAGETAG --build-arg WINDOWS_VERSION=ltsc2019 --build-arg IMAGE_TAG=$env:IMAGETAG_TELEMETRY
- name: List-docker-images
run: docker images --digests --all

96 changes: 84 additions & 12 deletions .pipelines/azure_pipeline_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
pool:
name: Azure-Pipelines-CI-Test-EO
variables:
linuxImagetag: $[ dependencies.common.outputs['setup.linuxImagetag'] ]
linuxImagetag: $[ dependencies.common.outputs['setup.linuxImagetag'] ]

steps:
- task: AzureCLI@2
Expand Down Expand Up @@ -141,13 +141,14 @@ jobs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: drop

- job: build_windows
dependsOn: common
- job: build_windows_2019
dependsOn:
- common
pool:
name: Azure-Pipelines-Windows-CI-Test-EO
variables:
windowsImageTag: $[ dependencies.common.outputs['setup.windowsImageTag'] ]

windowsImageTag: $[ dependencies.common.outputs['setup.windowsImageTag'] ]
windows2019BaseImageVersion: ltsc2019
steps:
- task: PowerShell@2
inputs:
Expand All @@ -163,7 +164,7 @@ jobs:
displayName: 'build base'
- task: AzureCLI@2
displayName: "Docker windows build"
displayName: "Docker windows build for ltsc2019"
inputs:
azureSubscription: ${{ variables.armServiceConnectionName }}
scriptType: ps
Expand All @@ -177,28 +178,99 @@ jobs:
az account set -s ${{ variables.subscription }}
az acr login -n ${{ variables.containerRegistry }}
@{"image.name"="${{ variables.repoImageName }}:$(windowsImageTag)"} | ConvertTo-Json -Compress | Out-File -Encoding ascii $(Build.ArtifactStagingDirectory)/windows/metadata.json
docker build --isolation=hyperv --tag ${{ variables.repoImageName }}:$(windowsImageTag)-$(windows2019BaseImageVersion) --build-arg WINDOWS_VERSION=$(windows2019BaseImageVersion) --build-arg IMAGE_TAG=$(windowsImageTag) .
if ("$(Build.Reason)" -ne "PullRequest") {
docker push ${{ variables.repoImageName }}:$(windowsImageTag)-$(windows2019BaseImageVersion)
}
docker build --tag ${{ variables.repoImageName }}:$(windowsImageTag) --build-arg IMAGE_TAG=$(windowsImageTag) .
- job: build_windows_2022
dependsOn:
- common
pool:
name: Azure-Pipelines-Windows-CI-Test-EO
variables:
windowsImageTag: $[ dependencies.common.outputs['setup.windowsImageTag'] ]
windows2022BaseImageVersion: ltsc2022
steps:
- task: PowerShell@2
inputs:
targetType: 'filePath'
filePath: $(System.DefaultWorkingDirectory)/scripts/build/windows/install-build-pre-requisites.ps1
displayName: 'install prereqs'

- script: |
setlocal enabledelayedexpansion
powershell.exe -ExecutionPolicy Unrestricted -NoProfile -WindowStyle Hidden -File "build\windows\Makefile.ps1"
endlocal
exit /B %ERRORLEVEL%
displayName: 'build base'
- task: AzureCLI@2
displayName: "Docker windows build for ltsc2022"
inputs:
azureSubscription: ${{ variables.armServiceConnectionName }}
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
mkdir -p $(Build.ArtifactStagingDirectory)/windows
cd kubernetes/windows
az --version
az account show
az account set -s ${{ variables.subscription }}
az acr login -n ${{ variables.containerRegistry }}
docker build --isolation=hyperv --tag ${{ variables.repoImageName }}:$(windowsImageTag)-$(windows2022BaseImageVersion) --build-arg WINDOWS_VERSION=$(windows2022BaseImageVersion) --build-arg IMAGE_TAG=$(windowsImageTag) .
if ("$(Build.Reason)" -ne "PullRequest") {
docker push ${{ variables.repoImageName }}:$(windowsImageTag)
docker push ${{ variables.repoImageName }}:$(windowsImageTag)-$(windows2022BaseImageVersion)
}
- job: build_windows_multi_arc
dependsOn:
- common
- build_windows_2019
- build_windows_2022
pool:
name: Azure-Pipelines-Windows-CI-Test-EO
variables:
windowsImageTag: $[ dependencies.common.outputs['setup.windowsImageTag'] ]
windows2019BaseImageVersion: ltsc2019
windows2022BaseImageVersion: ltsc2022
steps:
- task: AzureCLI@2
displayName: "Docker windows build for multi-arc image"
inputs:
azureSubscription: ${{ variables.armServiceConnectionName }}
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
mkdir -p $(Build.ArtifactStagingDirectory)/windows
cd kubernetes/windows
az --version
az account show
az account set -s ${{ variables.subscription }}
az acr login -n ${{ variables.containerRegistry }}
@{"image.name"="${{ variables.repoImageName }}:$(windowsImageTag)"} | ConvertTo-Json -Compress | Out-File -Encoding ascii $(Build.ArtifactStagingDirectory)/windows/metadata.json
if ("$(Build.Reason)" -ne "PullRequest") {
docker manifest create ${{ variables.repoImageName }}:$(windowsImageTag) ${{ variables.repoImageName }}:$(windowsImageTag)-$(windows2019BaseImageVersion) ${{ variables.repoImageName }}:$(windowsImageTag)-$(windows2022BaseImageVersion)
docker manifest push ${{ variables.repoImageName }}:$(windowsImageTag)
}
- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
displayName: 'Generation Task'
condition: eq(variables.IS_PR, true)
inputs:
BuildDropPath: '$(Build.ArtifactStagingDirectory)/windows'
DockerImagesToScan: 'mcr.microsoft.com/windows/servercore:ltsc2019'
DockerImagesToScan: 'mcr.microsoft.com/windows/servercore:ltsc2019, mcr.microsoft.com/windows/servercore:ltsc2022'

- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
displayName: 'Generation Task'
condition: eq(variables.IS_PR, false)
inputs:
BuildDropPath: '$(Build.ArtifactStagingDirectory)/windows'
DockerImagesToScan: 'mcr.microsoft.com/windows/servercore:ltsc2019, ${{ variables.repoImageName }}:$(windowsImageTag)'

DockerImagesToScan: 'mcr.microsoft.com/windows/servercore:ltsc2019, mcr.microsoft.com/windows/servercore:ltsc2022, ${{ variables.repoImageName }}:$(windowsImageTag)'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
Expand Down
96 changes: 84 additions & 12 deletions .pipelines/azure_pipeline_prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
pool:
name: Azure-Pipelines-CI-Prod-EO
variables:
linuxImagetag: $[ dependencies.common.outputs['setup.linuxImagetag'] ]
linuxImagetag: $[ dependencies.common.outputs['setup.linuxImagetag'] ]

steps:
- task: AzureCLI@2
Expand Down Expand Up @@ -146,13 +146,14 @@ jobs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: drop

- job: build_windows
dependsOn: common
- job: build_windows_2019
dependsOn:
- common
pool:
name: Azure-Pipelines-Windows-CI-Prod-EO
variables:
windowsImageTag: $[ dependencies.common.outputs['setup.windowsImageTag'] ]

windowsImageTag: $[ dependencies.common.outputs['setup.windowsImageTag'] ]
windows2019BaseImageVersion: ltsc2019
steps:
- task: PowerShell@2
inputs:
Expand All @@ -168,7 +169,7 @@ jobs:
displayName: 'build base'
- task: AzureCLI@2
displayName: "Docker windows build"
displayName: "Docker windows build for ltsc2019"
inputs:
azureSubscription: ${{ variables.armServiceConnectionName }}
scriptType: ps
Expand All @@ -182,28 +183,99 @@ jobs:
az account set -s ${{ variables.subscription }}
az acr login -n ${{ variables.containerRegistry }}
@{"image.name"="${{ variables.repoImageNameWindows }}:$(windowsImageTag)"} | ConvertTo-Json -Compress | Out-File -Encoding ascii $(Build.ArtifactStagingDirectory)/windows/metadata.json
docker build --isolation=hyperv --tag ${{ variables.repoImageNameWindows }}:$(windowsImageTag)-$(windows2019BaseImageVersion) --build-arg WINDOWS_VERSION=$(windows2019BaseImageVersion) .
if ("$(Build.Reason)" -ne "PullRequest") {
docker push ${{ variables.repoImageNameWindows }}:$(windowsImageTag)-$(windows2019BaseImageVersion)
}
docker build --tag ${{ variables.repoImageNameWindows }}:$(windowsImageTag) .
- job: build_windows_2022
dependsOn:
- common
pool:
name: Azure-Pipelines-Windows-CI-Prod-EO
variables:
windowsImageTag: $[ dependencies.common.outputs['setup.windowsImageTag'] ]
windows2022BaseImageVersion: ltsc2022
steps:
- task: PowerShell@2
inputs:
targetType: 'filePath'
filePath: $(System.DefaultWorkingDirectory)/scripts/build/windows/install-build-pre-requisites.ps1
displayName: 'install prereqs'

- script: |
setlocal enabledelayedexpansion
powershell.exe -ExecutionPolicy Unrestricted -NoProfile -WindowStyle Hidden -File "build\windows\Makefile.ps1"
endlocal
exit /B %ERRORLEVEL%
displayName: 'build base'
- task: AzureCLI@2
displayName: "Docker windows build for ltsc2022"
inputs:
azureSubscription: ${{ variables.armServiceConnectionName }}
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
mkdir -p $(Build.ArtifactStagingDirectory)/windows
cd kubernetes/windows
az --version
az account show
az account set -s ${{ variables.subscription }}
az acr login -n ${{ variables.containerRegistry }}
docker build --isolation=hyperv --tag ${{ variables.repoImageNameWindows }}:$(windowsImageTag)-$(windows2022BaseImageVersion) --build-arg WINDOWS_VERSION=$(windows2022BaseImageVersion) .
if ("$(Build.Reason)" -ne "PullRequest") {
docker push ${{ variables.repoImageNameWindows }}:$(windowsImageTag)
docker push ${{ variables.repoImageNameWindows }}:$(windowsImageTag)-$(windows2022BaseImageVersion)
}
- job: build_windows_multi_arc
dependsOn:
- common
- build_windows_2019
- build_windows_2022
pool:
name: Azure-Pipelines-Windows-CI-Prod-EO
variables:
windowsImageTag: $[ dependencies.common.outputs['setup.windowsImageTag'] ]
windows2019BaseImageVersion: ltsc2019
windows2022BaseImageVersion: ltsc2022
steps:
- task: AzureCLI@2
displayName: "Docker windows build for multi-arc image"
inputs:
azureSubscription: ${{ variables.armServiceConnectionName }}
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
mkdir -p $(Build.ArtifactStagingDirectory)/windows
cd kubernetes/windows
az --version
az account show
az account set -s ${{ variables.subscription }}
az acr login -n ${{ variables.containerRegistry }}
@{"image.name"="${{ variables.repoImageNameWindows }}:$(windowsImageTag)"} | ConvertTo-Json -Compress | Out-File -Encoding ascii $(Build.ArtifactStagingDirectory)/windows/metadata.json
if ("$(Build.Reason)" -ne "PullRequest") {
docker manifest create ${{ variables.repoImageNameWindows }}:$(windowsImageTag) ${{ variables.repoImageNameWindows }}:$(windowsImageTag)-$(windows2019BaseImageVersion) ${{ variables.repoImageNameWindows }}:$(windowsImageTag)-$(windows2022BaseImageVersion)
docker manifest push ${{ variables.repoImageNameWindows }}:$(windowsImageTag)
}
- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
displayName: 'Generation Task'
condition: eq(variables.IS_PR, true)
inputs:
BuildDropPath: '$(Build.ArtifactStagingDirectory)/windows'
DockerImagesToScan: 'mcr.microsoft.com/windows/servercore:ltsc2019'
DockerImagesToScan: 'mcr.microsoft.com/windows/servercore:ltsc2019, mcr.microsoft.com/windows/servercore:ltsc2022'

- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
displayName: 'Generation Task'
condition: eq(variables.IS_PR, false)
inputs:
BuildDropPath: '$(Build.ArtifactStagingDirectory)/windows'
DockerImagesToScan: 'mcr.microsoft.com/windows/servercore:ltsc2019, ${{ variables.repoImageNameWindows }}:$(windowsImageTag)'

DockerImagesToScan: 'mcr.microsoft.com/windows/servercore:ltsc2019, mcr.microsoft.com/windows/servercore:ltsc2022, ${{ variables.repoImageName }}:$(windowsImageTag)'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,28 @@ powershell -ExecutionPolicy bypass # switch to powershell if you are not on pow
And then run the script to build the image consisting of code and conf changes.
```
.\build-and-publish-dev-docker-image.ps1 -image <repo>/<imagename>:<imagetag> # trigger build code and image and publish docker hub or acr
By default, multi-arc docker image will be built, but if you want generate test image either with ltsc2019 or ltsc2022 base image, then you can follow the instructions below
For building image with base image version ltsc2019
.\build-and-publish-dev-docker-image.ps1 -image <repo>/<imagename>:<imagetag> -windowsBaseImageVersion ltsc2019
For building image with base image version ltsc2022
.\build-and-publish-dev-docker-image.ps1 -image <repo>/<imagename>:<imagetag> -windowsBaseImageVersion ltsc2022
```

For the subsequent builds, you can just run -

```
.\build-and-publish-dev-docker-image.ps1 -image <repo>/<imagename>:<imagetag> # trigger build code and image and publish docker hub or acr
By default, multi-arc docker image will be built, but if you want generate test image either with ltsc2019 or ltsc2022 base image, then you can follow the instructions below
For building image with base image version ltsc2019
.\build-and-publish-dev-docker-image.ps1 -image <repo>/<imagename>:<imagetag> -windowsBaseImageVersion ltsc2019
For building image with base image version ltsc2022
.\build-and-publish-dev-docker-image.ps1 -image <repo>/<imagename>:<imagetag> -windowsBaseImageVersion ltsc2022
```
###### Note - If you have changes in setup.ps1 and want to test those changes, uncomment the section consisting of setup.ps1 in the Dockerfile-dev-image file.

Expand Down
4 changes: 3 additions & 1 deletion kubernetes/windows/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM mcr.microsoft.com/windows/servercore:ltsc2019
# Supported values of windows version are ltsc2019 or ltsc2022 which are being passed by the build script or build pipeline
ARG WINDOWS_VERSION=
FROM mcr.microsoft.com/windows/servercore:${WINDOWS_VERSION}
MAINTAINER [email protected]
LABEL vendor=Microsoft\ Corp \
com.microsoft.product="Azure Monitor for containers"
Expand Down
3 changes: 2 additions & 1 deletion kubernetes/windows/Dockerfile-dev-base-image
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM mcr.microsoft.com/windows/servercore:ltsc2019
ARG WINDOWS_VERSION=
FROM mcr.microsoft.com/windows/servercore:${WINDOWS_VERSION}
MAINTAINER [email protected]
LABEL vendor=Microsoft\ Corp \
com.microsoft.product="Azure Monitor for containers"
Expand Down
Loading

0 comments on commit 0da25a7

Please sign in to comment.