Skip to content

Commit b5b5dcc

Browse files
authored
Merge pull request #5162 from claudiubelu/integration-test-images
integration: Windows volume-copy-up images
2 parents ce3d6e9 + 16deba0 commit b5b5dcc

3 files changed

Lines changed: 108 additions & 11 deletions

File tree

integration/images/volume-copy-up/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM busybox
15+
ARG BASE
16+
17+
FROM $BASE
1618
RUN sh -c "mkdir /test_dir; echo test_content > /test_dir/test_file"
1719
VOLUME "/test_dir"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright The containerd Authors.
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ARG BASE
16+
17+
FROM --platform=linux/amd64 busybox as prep
18+
19+
# Similar to: https://github.com/kubernetes/kubernetes/blob/7ad7c0757ac7fa37dfae9c7cdc628cf04e35e5cb/test/images/busybox/Dockerfile_windows
20+
21+
# Available busybox functions retrieved by running busybox.exe --list
22+
ENV BUSYBOX_EXES="[ [[ ar arch ash awk base64 basename bash bunzip2 bzcat bzip2 cal cat chmod cksum clear cmp comm cp cpio cut date dc dd df diff dirname dos2unix dpkg-deb du echo ed egrep env expand expr factor false fgrep find fold fsync ftpget ftpput getopt grep groups gunzip gzip hd head hexdump id ipcalc kill killall less link ln logname ls lzcat lzma lzop lzopcat man md5sum mkdir mktemp mv nl od paste patch pgrep pidof pipe_progress pkill printenv printf ps pwd rev rm rmdir rpm rpm2cpio sed seq sh sha1sum sha256sum sha3sum sha512sum shred shuf sleep sort split ssl_client stat strings sum tac tail tar tee test timeout touch tr true truncate ttysize uname uncompress unexpand uniq unix2dos unlink unlzma unlzop unxz unzip usleep uudecode uuencode vi watch wc wget which whoami whois xargs xxd xz xzcat yes zcat"
23+
24+
ADD https://github.com/kubernetes-sigs/windows-testing/raw/master/images/busybox/busybox.exe /busybox-dir/busybox.exe
25+
26+
# NOTE(claudiub): We're creating symlinks for each of the busybox binaries and after that we're copying
27+
# # them over to Windows. Unfortunately, docker buildx has some issues copying over Windows symlinks.
28+
# # "Files/" is always prepended to the symlink target. The symlinks themselves are relative paths,
29+
# # so, in order to make use of them, we can simply add a busybox binary to Files\busybox.exe.
30+
RUN cd /busybox-dir/ && \
31+
for busybox_binary in $BUSYBOX_EXES; do ln -s busybox.exe $busybox_binary.exe; done && \
32+
mkdir Files && \
33+
cp busybox.exe Files/busybox.exe
34+
35+
RUN sh -c "mkdir /test_dir; echo test_content > /test_dir/test_file"
36+
37+
FROM $BASE
38+
39+
COPY --from=prep /busybox-dir /bin
40+
COPY --from=prep /test_dir /test_dir
41+
ENV PATH="C:\bin;C:\Windows\System32;C:\Windows;"
42+
VOLUME "/test_dir"

integration/images/volume-copy-up/Makefile

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,73 @@
1515
all: build
1616

1717
PROJ=gcr.io/k8s-cri-containerd
18-
VERSION=2.0
18+
VERSION=2.1
1919
IMAGE=$(PROJ)/volume-copy-up:$(VERSION)
20-
PLATFORMS?=linux/amd64,linux/arm64
20+
21+
# Operating systems supported: linux, windows
22+
OS ?= linux
23+
# Architectures supported: amd64, arm64
24+
ARCH ?= amd64
25+
# OS Version for the Windows images: 1809, 2004, 20H2
26+
OSVERSION ?= 1809
27+
28+
# The output type could either be docker (local), or registry.
29+
# If it is registry, it will also allow us to push the Windows images.
30+
OUTPUT_TYPE ?= docker
31+
32+
ALL_OS = linux windows
33+
ALL_ARCH.linux = amd64 arm64
34+
ALL_OS_ARCH.linux = $(foreach arch, ${ALL_ARCH.linux}, linux-$(arch))
35+
ALL_OSVERSIONS.windows := 1809 2004 20H2
36+
ALL_OS_ARCH.windows = $(foreach osversion, ${ALL_OSVERSIONS.windows}, windows-amd64-${osversion})
37+
ALL_OS_ARCH = $(foreach os, $(ALL_OS), ${ALL_OS_ARCH.${os}})
38+
39+
BASE.linux.amd64 := busybox
40+
BASE.linux.arm64 := arm64v8/busybox
41+
BASE.linux := ${BASE.linux.${ARCH}}
42+
BASE.windows := mcr.microsoft.com/windows/nanoserver
43+
BASE := ${BASE.${OS}}
2144

2245
configure-docker:
2346
gcloud auth configure-docker
2447

25-
build:
26-
docker buildx build \
27-
$(OUTPUT) \
28-
--platform=${PLATFORMS} \
29-
--tag $(IMAGE) .
48+
setup-buildx:
49+
docker buildx use img-builder || docker buildx create --name img-builder --use
50+
51+
build: setup-buildx build-local
52+
53+
push: configure-docker setup-buildx build-registry push-manifest
54+
55+
build-local: $(addprefix sub-container-docker-,$(ALL_OS_ARCH.linux))
56+
build-registry: $(addprefix sub-container-registry-,$(ALL_OS_ARCH))
57+
58+
# split words on hyphen, access by 1-index
59+
word-hyphen = $(word $2,$(subst -, ,$1))
60+
sub-container-%:
61+
$(MAKE) OUTPUT_TYPE=$(call word-hyphen,$*,1) OS=$(call word-hyphen,$*,2) ARCH=$(call word-hyphen,$*,3) OSVERSION=$(call word-hyphen,$*,4) container
62+
63+
container: .container-${OS}-$(ARCH)
64+
65+
.container-linux-$(ARCH):
66+
docker buildx build --pull --output=type=${OUTPUT_TYPE} --platform ${OS}/${ARCH} \
67+
-t $(IMAGE)-${OS}-${ARCH} --build-arg BASE=${BASE} .
68+
69+
.container-windows-$(ARCH):
70+
docker buildx build --pull --output=type=${OUTPUT_TYPE} --platform ${OS}/${ARCH} \
71+
-t $(IMAGE)-${OS}-${ARCH}-${OSVERSION} --build-arg BASE=${BASE}:${OSVERSION} \
72+
-f Dockerfile_windows .
3073

31-
push: OUTPUT=--push
32-
push: configure-docker build
74+
# For Windows images, we also need to include the "os.version" in the manifest list images,
75+
# so the Windows node can pull the proper image it needs.
76+
push-manifest:
77+
docker manifest create --amend $(IMAGE) $(shell echo $(ALL_OS_ARCH) | sed -e "s~[^ ]*~$(IMAGE)\-&~g")
78+
set -x; for arch in $(ALL_ARCH.linux); do docker manifest annotate --os linux --arch $${arch} ${IMAGE} ${IMAGE}-linux-$${arch}; done
79+
# we use awk to also trim the quotes around the OS version string.
80+
set -x; \
81+
for osversion in ${ALL_OSVERSIONS.windows}; do \
82+
full_version=`docker manifest inspect ${BASE.windows}:$${osversion} | grep "os.version" | head -n 1 | awk -F\" '{print $$4}'` || true; \
83+
docker manifest annotate --os windows --arch amd64 --os-version $${full_version} ${IMAGE} ${IMAGE}-windows-amd64-$${osversion}; \
84+
done
85+
docker manifest push --purge ${IMAGE}
3386

34-
.PHONY: configure-docker build push
87+
.PHONY: configure-docker setup-buildx build push build-local build-registry container push-manifest

0 commit comments

Comments
 (0)