Skip to content

Commit 16b3e16

Browse files
authored
Enhance Windows CI Compatibility with Different Docker Registry (#7033)
When a user switches the Docker registry for image access, building Windows images still pulls images from the default registry. This patch improves compatibility for registry changes. Signed-off-by: Shuyang Xin <[email protected]>
1 parent d3087fd commit 16b3e16

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

build/images/Dockerfile.build.windows

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
ARG GO_VERSION
1616
ARG OVS_VERSION
17+
ARG DOCKER_REGISTRY="docker.io"
1718

1819
FROM --platform=linux/amd64 golang:${GO_VERSION} AS antrea-build-windows
1920
ARG CNI_BINARIES_VERSION
@@ -43,7 +44,7 @@ RUN mkdir -p /go/k/antrea/bin && \
4344
cp /antrea/bin/antrea-cni.exe /go/k/antrea/cni/antrea.exe && \
4445
cp /antrea/hack/windows/Install-OVS.ps1 /go/k/antrea/
4546

46-
FROM antrea/windows-ovs:${OVS_VERSION} AS antrea-ovs
47+
FROM ${DOCKER_REGISTRY}/antrea/windows-ovs:${OVS_VERSION} AS antrea-ovs
4748

4849
FROM mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0
4950
COPY --from=antrea-build-windows /go/k /k

build/images/build-windows.sh

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ registry="antrea"
7373
image_name="antrea-windows"
7474
image="${registry}/${image_name}"
7575
BUILD_ARGS="--build-arg GO_VERSION=${GO_VERSION} --build-arg OVS_VERSION=${OVS_VERSION} --build-arg CNI_BINARIES_VERSION=${CNI_BINARIES_VERSION}"
76+
if [[ ${DOCKER_REGISTRY} != "" ]]; then
77+
BUILD_ARGS+=" --build-arg DOCKER_REGISTRY=${DOCKER_REGISTRY}"
78+
fi
7679

7780
ANTREA_DIR=${THIS_DIR}/../../
7881
pushd $ANTREA_DIR > /dev/null

build/images/ovs/build.sh

+9-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,12 @@ if $PULL; then
132132
docker pull $PLATFORM_ARG quay.io/centos/centos:stream9
133133
docker pull $PLATFORM_ARG registry.access.redhat.com/ubi9
134134
elif [ "$DISTRO" == "windows" ]; then
135-
docker pull --platform linux/amd64 ubuntu:24.04
135+
if [[ ${DOCKER_REGISTRY} == "" ]]; then
136+
docker pull --platform linux/amd64 ubuntu:24.04
137+
else
138+
docker pull --platform linux/amd64 ${DOCKER_REGISTRY}/antrea/ubuntu:24.04
139+
docker tag ${DOCKER_REGISTRY}/antrea/ubuntu:24.04 ubuntu:24.04
140+
fi
136141
fi
137142
fi
138143

@@ -163,6 +168,9 @@ elif [ "$DISTRO" == "ubi" ]; then
163168
elif [ "$DISTRO" == "windows" ]; then
164169
image="antrea/windows-ovs"
165170
build_args="--build-arg OVS_VERSION=$OVS_VERSION"
171+
if [[ ${DOCKER_REGISTRY} != "" ]]; then
172+
image="${DOCKER_REGISTRY}/antrea/windows-ovs"
173+
fi
166174
docker_build_and_push_windows "${image}" "Dockerfile.windows" "${build_args}" "${OVS_VERSION}" $PUSH ""
167175
fi
168176

ci/jenkins/test.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ function deliver_antrea_linux {
476476
function deliver_antrea_windows {
477477
echo "===== Build Antrea Windows ====="
478478
rm -f antrea-windows.tar.gz
479-
make build-windows
479+
DOCKER_REGISTRY="${DOCKER_REGISTRY}" ./hack/build-antrea-windows-all.sh --pull
480480
if ! (test -f antrea-windows.tar); then
481481
echo "antrea-windows.tar wasn't built, exiting"
482482
exit 1
@@ -489,7 +489,7 @@ function deliver_antrea_windows {
489489
revert_snapshot_windows ${WORKER_NAME}
490490
k8s_images=("registry.k8s.io/e2e-test-images/agnhost:2.52" "registry.k8s.io/e2e-test-images/jessie-dnsutils:1.5" "registry.k8s.io/e2e-test-images/nginx:1.14-2" "registry.k8s.io/pause:3.10")
491491
conformance_images=("k8sprow.azurecr.io/kubernetes-e2e-test-images/agnhost:2.52" "k8sprow.azurecr.io/kubernetes-e2e-test-images/jessie-dnsutils:1.5" "k8sprow.azurecr.io/kubernetes-e2e-test-images/nginx:1.14-2" "registry.k8s.io/e2e-test-images/pause:3.10")
492-
e2e_images=("${DOCKER_REGISTRY}/antrea/toolbox:1.4-0" "registry.k8s.io/e2e-test-images/agnhost:2.40")
492+
e2e_images=("${DOCKER_REGISTRY}/antrea/toolbox:1.5-1" "registry.k8s.io/e2e-test-images/agnhost:2.40")
493493
# Pull necessary images in advance to avoid transient error
494494
for i in "${!k8s_images[@]}"; do
495495
ssh -o StrictHostKeyChecking=no -n Administrator@${IP} "ctr -n k8s.io images pull --user ${DOCKER_USERNAME}:${DOCKER_PASSWORD} ${k8s_images[i]} && ctr -n k8s.io images tag ${k8s_images[i]} ${conformance_images[i]}" || true

hack/build-antrea-windows-all.sh

+9
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ cd build/images/ovs
8686
./build.sh --distro windows $ARGS
8787
cd -
8888

89+
GO_VERSION=$(head -n 1 build/images/deps/go-version)
90+
91+
if [[ "${DOCKER_REGISTRY}" == "" ]]; then
92+
docker pull --platform linux/amd64 golang:$GO_VERSION
93+
else
94+
docker pull --platform linux/amd64 ${DOCKER_REGISTRY}/antrea/golang:$GO_VERSION
95+
docker tag ${DOCKER_REGISTRY}/antrea/golang:$GO_VERSION $GO_VERSION
96+
fi
97+
8998
if $PUSH_AGENT; then
9099
make build-and-push-windows
91100
else

0 commit comments

Comments
 (0)