Skip to content

Commit 2b1e0b0

Browse files
author
Lu-David
committed
added windows 2022 support
1 parent eb3c7d0 commit 2b1e0b0

File tree

6 files changed

+75
-24
lines changed

6 files changed

+75
-24
lines changed

.github/workflows/build-and-test.yaml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ jobs:
124124

125125
buildWindows:
126126
name: Build Windows Binaries
127-
runs-on: windows-2019
127+
strategy:
128+
matrix:
129+
version: [2019, 2022]
130+
runs-on: windows-${{matrix.version}}
128131
steps:
129132
- name: Set up Go 1.x
130133
uses: actions/setup-go@v2
@@ -149,11 +152,14 @@ jobs:
149152
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
150153
refreshenv
151154
152-
choco install make && choco install zip && make build-binaries-windows
155+
choco install make && choco install zip && make build-binaries-windows-${{matrix.version}}
153156
154157
buildWindowsDocker:
155158
name: Build Windows Docker Images
156-
runs-on: windows-2019
159+
strategy:
160+
matrix:
161+
version: [2019, 2022]
162+
runs-on: windows-${{matrix.version}}
157163
steps:
158164
- name: Set up Go 1.x
159165
uses: actions/setup-go@v2
@@ -178,7 +184,7 @@ jobs:
178184
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
179185
refreshenv
180186
181-
choco install make && make build-docker-images-windows
187+
choco install make && make build-docker-images-windows-${{matrix.version}}
182188
183189
e2e:
184190
name: E2E Tests
@@ -205,4 +211,4 @@ jobs:
205211
key: gocache
206212

207213
- name: E2E Tests
208-
run: test/k8s-local-cluster-test/run-test -v ${{ matrix.k8sVersion }}
214+
run: test/k8s-local-cluster-test/run-test -v ${{ matrix.k8sVersion }}

.github/workflows/release.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ jobs:
3636

3737
releaseWindows:
3838
name: Release Windows
39-
runs-on: windows-2019
4039
needs: [releaseLinux]
40+
strategy:
41+
matrix:
42+
version: [2019, 2022]
43+
runs-on: windows-${{matrix.version}}
4144
steps:
4245
- name: Set up Go 1.x
4346
uses: actions/setup-go@v2
@@ -53,7 +56,7 @@ jobs:
5356
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
5457
refreshenv
5558
56-
choco install make && choco install zip && make release-windows
59+
choco install make && choco install zip && make release-windows-${{matrix.version}}
5760
env:
5861
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
5962
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
@@ -91,4 +94,4 @@ jobs:
9194
env:
9295
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
9396
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
94-
AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }}
97+
AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }}

Makefile

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,16 @@ MAKEFILE_PATH = $(dir $(realpath -s $(firstword $(MAKEFILE_LIST))))
1717
BUILD_DIR_PATH = ${MAKEFILE_PATH}/build
1818
BIN_DIR = ${MAKEFILE_PATH}/bin
1919
SUPPORTED_PLATFORMS_LINUX ?= "linux/amd64,linux/arm64"
20-
SUPPORTED_PLATFORMS_WINDOWS ?= "windows/amd64"
20+
21+
# Each windows version needs a separate make target because each build
22+
# needs to happen on a separate GitHub runner
23+
# A windows version is specified by major-minor-build-revision.
24+
# The build number of the OS must match the build number of the container image
25+
# The revision does not matter for windows 2019 and 2022.
26+
# Reference: https://learn.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility
27+
WINDOWS_2019 ?= "windows-10.0.17763.6189/amd64"
28+
WINDOWS_2022 ?= "windows-10.0.20348.2582/amd64"
29+
2130
BINARY_NAME ?= "node-termination-handler"
2231
THIRD_PARTY_LICENSES = "${MAKEFILE_PATH}/THIRD_PARTY_LICENSES.md"
2332
GOLICENSES = $(BIN_DIR)/go-licenses
@@ -48,18 +57,32 @@ docker-run:
4857
build-docker-images:
4958
${MAKEFILE_PATH}/scripts/build-docker-images -p ${SUPPORTED_PLATFORMS_LINUX} -r ${IMG} -v ${VERSION}
5059

51-
build-docker-images-windows:
52-
${MAKEFILE_PATH}/scripts/build-docker-images -p ${SUPPORTED_PLATFORMS_WINDOWS} -r ${IMG} -v ${VERSION}
60+
build-docker-images-windows-2019:
61+
${MAKEFILE_PATH}/scripts/build-docker-images -p ${WINDOWS_2019} -r ${IMG} -v ${VERSION}
62+
63+
build-docker-images-windows-2022:
64+
${MAKEFILE_PATH}/scripts/build-docker-images -p ${WINDOWS_2022} -r ${IMG} -v ${VERSION}
65+
66+
ecr-public-login:
67+
@ECR_REGISTRY=${ECR_REGISTRY} ${MAKEFILE_PATH}/scripts/ecr-public-login
5368

5469
push-docker-images:
5570
${MAKEFILE_PATH}/scripts/retag-docker-images -p ${SUPPORTED_PLATFORMS_LINUX} -v ${VERSION} -o ${IMG} -n ${ECR_REPO}
5671
@ECR_REGISTRY=${ECR_REGISTRY} ${MAKEFILE_PATH}/scripts/ecr-public-login
5772
${MAKEFILE_PATH}/scripts/push-docker-images -p ${SUPPORTED_PLATFORMS_LINUX} -r ${ECR_REPO} -v ${VERSION} -m
5873

59-
push-docker-images-windows:
60-
${MAKEFILE_PATH}/scripts/retag-docker-images -p ${SUPPORTED_PLATFORMS_WINDOWS} -v ${VERSION} -o ${IMG} -n ${ECR_REPO}
74+
amazon-ecr-credential-helper:
6175
bash ${MAKEFILE_PATH}/scripts/install-amazon-ecr-credential-helper $(AMAZON_ECR_CREDENTIAL_HELPER_VERSION)
62-
${MAKEFILE_PATH}/scripts/push-docker-images -p ${SUPPORTED_PLATFORMS_WINDOWS} -r ${ECR_REPO} -v ${VERSION} -m
76+
77+
push-docker-images-windows-2019:
78+
${MAKEFILE_PATH}/scripts/retag-docker-images -p ${WINDOWS_2019} -v ${VERSION} -o ${IMG} -n ${ECR_REPO}
79+
bash ${MAKEFILE_PATH}/scripts/install-amazon-ecr-credential-helper $(AMAZON_ECR_CREDENTIAL_HELPER_VERSION)
80+
${MAKEFILE_PATH}/scripts/push-docker-images -p ${WINDOWS_2019} -r ${ECR_REPO} -v ${VERSION} -m
81+
82+
push-docker-images-windows-2022:
83+
${MAKEFILE_PATH}/scripts/retag-docker-images -p ${WINDOWS_2022} -v ${VERSION} -o ${IMG} -n ${ECR_REPO}
84+
bash ${MAKEFILE_PATH}/scripts/install-amazon-ecr-credential-helper $(AMAZON_ECR_CREDENTIAL_HELPER_VERSION)
85+
${MAKEFILE_PATH}/scripts/push-docker-images -p ${WINDOWS_2022} -r ${ECR_REPO} -v ${VERSION} -m
6386

6487
push-helm-chart:
6588
@ECR_REGISTRY=${ECR_REGISTRY} ${MAKEFILE_PATH}/scripts/helm-login
@@ -122,8 +145,11 @@ helm-validate-chart-versions:
122145
build-binaries:
123146
${MAKEFILE_PATH}/scripts/build-binaries -p ${SUPPORTED_PLATFORMS_LINUX} -v ${VERSION}
124147

125-
build-binaries-windows:
126-
${MAKEFILE_PATH}/scripts/build-binaries -p ${SUPPORTED_PLATFORMS_WINDOWS} -v ${VERSION}
148+
build-binaries-windows-2019:
149+
${MAKEFILE_PATH}/scripts/build-binaries -p ${WINDOWS_2019} -v ${VERSION}
150+
151+
build-binaries-windows-2022:
152+
${MAKEFILE_PATH}/scripts/build-binaries -p ${WINDOWS_2022} -v ${VERSION}
127153

128154
upload-resources-to-github:
129155
${MAKEFILE_PATH}/scripts/upload-resources-to-github
@@ -165,7 +191,9 @@ eks-cluster-test:
165191

166192
release: build-binaries build-docker-images push-docker-images generate-k8s-yaml upload-resources-to-github
167193

168-
release-windows: build-binaries-windows build-docker-images-windows push-docker-images-windows
194+
release-windows-2019: build-binaries-windows-2019 build-docker-images-windows-2019 push-docker-images-windows-2019
195+
196+
release-windows-2022: build-binaries-windows-2022 build-docker-images-windows-2022 push-docker-images-windows-2022
169197

170198
test: spellcheck shellcheck unit-test e2e-test compatibility-test license-test go-linter helm-version-sync-test helm-lint
171199

scripts/build-binaries

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ for os_arch in "${PLATFORMS[@]}"; do
4949
container_name="build-$BASE_BIN_NAME-$os-$arch"
5050
repo_name="bin-build"
5151

52-
if [[ $os == "windows" ]]; then
52+
if [[ $os == "windows"* ]]; then
5353
bin_name="$BASE_BIN_NAME-$os-$arch.exe"
5454
else
5555
bin_name="$BASE_BIN_NAME-$os-$arch"
@@ -60,7 +60,7 @@ for os_arch in "${PLATFORMS[@]}"; do
6060
docker container create --rm --name $container_name "$repo_name:$VERSION-$os-$arch"
6161
docker container cp $container_name:/${BASE_BIN_NAME} $BIN_DIR/$bin_name
6262

63-
if [[ $os == "windows" ]]; then
63+
if [[ $os == "windows"* ]]; then
6464
## Create zip archive with binary taking into account windows .exe
6565
cp ${BIN_DIR}/${bin_name} ${BIN_DIR}/${BASE_BIN_NAME}.exe
6666
## Can't reuse bin_name below because it includes .exe

scripts/build-docker-images

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,23 @@ for os_arch in "${PLATFORMS[@]}"; do
4848
os=$(echo $os_arch | cut -d'/' -f1)
4949
arch=$(echo $os_arch | cut -d'/' -f2)
5050

51-
img_tag="$IMAGE_REPO:$VERSION-$os-$arch"
52-
5351
dockerfile="$DOCKERFILE_PATH"
54-
if [[ $os = "windows" ]]; then
52+
if [[ $os == "windows"* ]]; then
53+
windows_version=$(echo $os | cut -d'-' -f2)
54+
os=$(echo $os | cut -d'-' -f1)
55+
img_tag="$IMAGE_REPO:$VERSION-$os-$windows_version-$arch"
5556
dockerfile="${dockerfile}.windows"
5657
docker build \
5758
--file "${dockerfile}" \
5859
--build-arg GOOS=${os} \
5960
--build-arg GOARCH=${arch} \
61+
--build-arg WINDOWS_VERSION=${windows_version} \
6062
--build-arg GOPROXY=${GOPROXY} \
6163
--tag ${img_tag} \
6264
${REPO_ROOT_PATH}
6365
else
6466
# Launch a docker buildx instance and save its name so we can terminate it later
67+
img_tag="$IMAGE_REPO:$VERSION-$os-$arch"
6568
buildx_instance_name=$(docker buildx create --use)
6669
docker buildx build \
6770
--load \

scripts/push-docker-images

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,17 @@ if [[ $MANIFEST == "true" ]]; then
6868
if [[ manifest_exists -eq 0 ]]; then
6969
echo "manifest already exists"
7070
EXISTING_IMAGES=()
71+
72+
# Run while loop to collect images with no OS version (typically linux)
73+
while IFS='' read -r line; do
74+
EXISTING_IMAGES+=("$line");
75+
done < <(docker manifest inspect $IMAGE_REPO:$VERSION | jq -r '.manifests[] | select(.platform."os.version" == null) | "\(.platform.os)-\(.platform.architecture)"')
76+
77+
# Run while loop to collect images with OS version (typically windows)
7178
while IFS='' read -r line; do
7279
EXISTING_IMAGES+=("$line");
73-
done < <(docker manifest inspect $IMAGE_REPO:$VERSION | jq -r '.manifests[] | "\(.platform.os)-\(.platform.architecture)"')
80+
done < <(docker manifest inspect $IMAGE_REPO:$VERSION | jq -r '.manifests[] | select(.platform."os.version" != null) | "\(.platform.os)-\(.platform."os.version")-\(.platform.architecture)"')
81+
7482
# treat separate from PLATFORMS because existing images don't need to be tagged and pushed
7583
for os_arch in "${EXISTING_IMAGES[@]}"; do
7684
img_tag="$IMAGE_REPO:$VERSION-$os_arch"
@@ -117,7 +125,10 @@ if [[ $MANIFEST == "true" ]]; then
117125
# However, our builds in the past required this explicit annotation, and it doesn't hurt to keep it for now.
118126
os_arch=$(echo ${updated_img//$IMAGE_REPO:$VERSION-/})
119127
os=$(echo $os_arch | cut -d'-' -f1)
120-
arch=$(echo $os_arch | cut -d'-' -f2)
128+
129+
# os_arch may be linux-amd64 or windows-10.0.17763.6189-amd64. To get the proper architecture, the bash command
130+
# will extract the last element after the hyphen (-).
131+
arch=${os_arch##*-}
121132

122133
echo "annotating manifest"
123134
docker manifest annotate $IMAGE_REPO:$VERSION $updated_img --arch $arch --os $os

0 commit comments

Comments
 (0)