Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ jobs:

buildWindows:
name: Build Windows Binaries
strategy:
matrix:
version: [2019, 2022]
runs-on: windows-${{matrix.version}}
runs-on: windows-2019
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
Expand All @@ -152,14 +149,11 @@ jobs:
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
refreshenv

choco install make && choco install zip && make build-binaries-windows-${{matrix.version}}
choco install make && choco install zip && make build-binaries-windows

buildWindowsDocker:
name: Build Windows Docker Images
strategy:
matrix:
version: [2019, 2022]
runs-on: windows-${{matrix.version}}
runs-on: windows-2019
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
Expand All @@ -184,7 +178,7 @@ jobs:
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
refreshenv

choco install make && make build-docker-images-windows-${{matrix.version}}
choco install make && make build-docker-images-windows

e2e:
name: E2E Tests
Expand All @@ -211,4 +205,4 @@ jobs:
key: gocache

- name: E2E Tests
run: test/k8s-local-cluster-test/run-test -v ${{ matrix.k8sVersion }}
run: test/k8s-local-cluster-test/run-test -v ${{ matrix.k8sVersion }}
9 changes: 3 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ jobs:

releaseWindows:
name: Release Windows
runs-on: windows-2019
needs: [releaseLinux]
strategy:
matrix:
version: [2019, 2022]
runs-on: windows-${{matrix.version}}
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
Expand All @@ -56,7 +53,7 @@ jobs:
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
refreshenv

choco install make && choco install zip && make release-windows-${{matrix.version}}
choco install make && choco install zip && make release-windows
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down Expand Up @@ -94,4 +91,4 @@ jobs:
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }}
AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }}
46 changes: 9 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,7 @@ MAKEFILE_PATH = $(dir $(realpath -s $(firstword $(MAKEFILE_LIST))))
BUILD_DIR_PATH = ${MAKEFILE_PATH}/build
BIN_DIR = ${MAKEFILE_PATH}/bin
SUPPORTED_PLATFORMS_LINUX ?= "linux/amd64,linux/arm64"

# Each windows version needs a separate make target because each build
# needs to happen on a separate GitHub runner
# A windows version is specified by major-minor-build-revision.
# The build number of the OS must match the build number of the container image
# The revision does not matter for windows 2019 and 2022.
# Reference: https://learn.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility
WINDOWS_2019 ?= "windows-10.0.17763.6189/amd64"
WINDOWS_2022 ?= "windows-10.0.20348.2582/amd64"

SUPPORTED_PLATFORMS_WINDOWS ?= "windows/amd64"
BINARY_NAME ?= "node-termination-handler"
THIRD_PARTY_LICENSES = "${MAKEFILE_PATH}/THIRD_PARTY_LICENSES.md"
GOLICENSES = $(BIN_DIR)/go-licenses
Expand Down Expand Up @@ -57,32 +48,18 @@ docker-run:
build-docker-images:
${MAKEFILE_PATH}/scripts/build-docker-images -p ${SUPPORTED_PLATFORMS_LINUX} -r ${IMG} -v ${VERSION}

build-docker-images-windows-2019:
${MAKEFILE_PATH}/scripts/build-docker-images -p ${WINDOWS_2019} -r ${IMG} -v ${VERSION}

build-docker-images-windows-2022:
${MAKEFILE_PATH}/scripts/build-docker-images -p ${WINDOWS_2022} -r ${IMG} -v ${VERSION}

ecr-public-login:
@ECR_REGISTRY=${ECR_REGISTRY} ${MAKEFILE_PATH}/scripts/ecr-public-login
build-docker-images-windows:
${MAKEFILE_PATH}/scripts/build-docker-images -p ${SUPPORTED_PLATFORMS_WINDOWS} -r ${IMG} -v ${VERSION}

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

amazon-ecr-credential-helper:
push-docker-images-windows:
${MAKEFILE_PATH}/scripts/retag-docker-images -p ${SUPPORTED_PLATFORMS_WINDOWS} -v ${VERSION} -o ${IMG} -n ${ECR_REPO}
bash ${MAKEFILE_PATH}/scripts/install-amazon-ecr-credential-helper $(AMAZON_ECR_CREDENTIAL_HELPER_VERSION)

push-docker-images-windows-2019:
${MAKEFILE_PATH}/scripts/retag-docker-images -p ${WINDOWS_2019} -v ${VERSION} -o ${IMG} -n ${ECR_REPO}
bash ${MAKEFILE_PATH}/scripts/install-amazon-ecr-credential-helper $(AMAZON_ECR_CREDENTIAL_HELPER_VERSION)
${MAKEFILE_PATH}/scripts/push-docker-images -p ${WINDOWS_2019} -r ${ECR_REPO} -v ${VERSION} -m

push-docker-images-windows-2022:
${MAKEFILE_PATH}/scripts/retag-docker-images -p ${WINDOWS_2022} -v ${VERSION} -o ${IMG} -n ${ECR_REPO}
bash ${MAKEFILE_PATH}/scripts/install-amazon-ecr-credential-helper $(AMAZON_ECR_CREDENTIAL_HELPER_VERSION)
${MAKEFILE_PATH}/scripts/push-docker-images -p ${WINDOWS_2022} -r ${ECR_REPO} -v ${VERSION} -m
${MAKEFILE_PATH}/scripts/push-docker-images -p ${SUPPORTED_PLATFORMS_WINDOWS} -r ${ECR_REPO} -v ${VERSION} -m

push-helm-chart:
@ECR_REGISTRY=${ECR_REGISTRY} ${MAKEFILE_PATH}/scripts/helm-login
Expand Down Expand Up @@ -145,11 +122,8 @@ helm-validate-chart-versions:
build-binaries:
${MAKEFILE_PATH}/scripts/build-binaries -p ${SUPPORTED_PLATFORMS_LINUX} -v ${VERSION}

build-binaries-windows-2019:
${MAKEFILE_PATH}/scripts/build-binaries -p ${WINDOWS_2019} -v ${VERSION}

build-binaries-windows-2022:
${MAKEFILE_PATH}/scripts/build-binaries -p ${WINDOWS_2022} -v ${VERSION}
build-binaries-windows:
${MAKEFILE_PATH}/scripts/build-binaries -p ${SUPPORTED_PLATFORMS_WINDOWS} -v ${VERSION}

upload-resources-to-github:
${MAKEFILE_PATH}/scripts/upload-resources-to-github
Expand Down Expand Up @@ -191,9 +165,7 @@ eks-cluster-test:

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

release-windows-2019: build-binaries-windows-2019 build-docker-images-windows-2019 push-docker-images-windows-2019

release-windows-2022: build-binaries-windows-2022 build-docker-images-windows-2022 push-docker-images-windows-2022
release-windows: build-binaries-windows build-docker-images-windows push-docker-images-windows

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

Expand Down
4 changes: 2 additions & 2 deletions scripts/build-binaries
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ for os_arch in "${PLATFORMS[@]}"; do
container_name="build-$BASE_BIN_NAME-$os-$arch"
repo_name="bin-build"

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

if [[ $os == "windows"* ]]; then
if [[ $os == "windows" ]]; then
## Create zip archive with binary taking into account windows .exe
cp ${BIN_DIR}/${bin_name} ${BIN_DIR}/${BASE_BIN_NAME}.exe
## Can't reuse bin_name below because it includes .exe
Expand Down
9 changes: 3 additions & 6 deletions scripts/build-docker-images
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,20 @@ for os_arch in "${PLATFORMS[@]}"; do
os=$(echo $os_arch | cut -d'/' -f1)
arch=$(echo $os_arch | cut -d'/' -f2)

img_tag="$IMAGE_REPO:$VERSION-$os-$arch"

dockerfile="$DOCKERFILE_PATH"
if [[ $os == "windows"* ]]; then
windows_version=$(echo $os | cut -d'-' -f2)
os=$(echo $os | cut -d'-' -f1)
img_tag="$IMAGE_REPO:$VERSION-$os-$windows_version-$arch"
if [[ $os = "windows" ]]; then
dockerfile="${dockerfile}.windows"
docker build \
--file "${dockerfile}" \
--build-arg GOOS=${os} \
--build-arg GOARCH=${arch} \
--build-arg WINDOWS_VERSION=${windows_version} \
--build-arg GOPROXY=${GOPROXY} \
--tag ${img_tag} \
${REPO_ROOT_PATH}
else
# Launch a docker buildx instance and save its name so we can terminate it later
img_tag="$IMAGE_REPO:$VERSION-$os-$arch"
buildx_instance_name=$(docker buildx create --use)
docker buildx build \
--load \
Expand Down
15 changes: 2 additions & 13 deletions scripts/push-docker-images
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,9 @@ if [[ $MANIFEST == "true" ]]; then
if [[ manifest_exists -eq 0 ]]; then
echo "manifest already exists"
EXISTING_IMAGES=()

# Run while loop to collect images with no OS version (typically linux)
while IFS='' read -r line; do
EXISTING_IMAGES+=("$line");
done < <(docker manifest inspect $IMAGE_REPO:$VERSION | jq -r '.manifests[] | select(.platform."os.version" == null) | "\(.platform.os)-\(.platform.architecture)"')

# Run while loop to collect images with OS version (typically windows)
while IFS='' read -r line; do
EXISTING_IMAGES+=("$line");
done < <(docker manifest inspect $IMAGE_REPO:$VERSION | jq -r '.manifests[] | select(.platform."os.version" != null) | "\(.platform.os)-\(.platform."os.version")-\(.platform.architecture)"')

done < <(docker manifest inspect $IMAGE_REPO:$VERSION | jq -r '.manifests[] | "\(.platform.os)-\(.platform.architecture)"')
# treat separate from PLATFORMS because existing images don't need to be tagged and pushed
for os_arch in "${EXISTING_IMAGES[@]}"; do
img_tag="$IMAGE_REPO:$VERSION-$os_arch"
Expand Down Expand Up @@ -125,10 +117,7 @@ if [[ $MANIFEST == "true" ]]; then
# However, our builds in the past required this explicit annotation, and it doesn't hurt to keep it for now.
os_arch=$(echo ${updated_img//$IMAGE_REPO:$VERSION-/})
os=$(echo $os_arch | cut -d'-' -f1)

# os_arch may be linux-amd64 or windows-10.0.17763.6189-amd64. To get the proper architecture, the bash command
# will extract the last element after the hyphen (-).
arch=${os_arch##*-}
arch=$(echo $os_arch | cut -d'-' -f2)

echo "annotating manifest"
docker manifest annotate $IMAGE_REPO:$VERSION $updated_img --arch $arch --os $os
Expand Down
Loading