From 4dbb55fe85f504de3e28eccf7987944df82ed686 Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Thu, 18 Apr 2019 14:38:12 +0000 Subject: [PATCH] test images: Adds Windows support (part 2) Adds Windows support for most of the images. Adds a README explaining the image building process, including the Windows Container image building process. --- build/dependencies.yaml | 2 +- test/images/echoserver/BASEIMAGE | 3 ++ test/images/echoserver/Dockerfile_windows | 39 +++++++++++++++++++ test/images/jessie-dnsutils/BASEIMAGE | 3 ++ .../images/jessie-dnsutils/Dockerfile_windows | 30 ++++++++++++++ test/images/nonroot/BASEIMAGE | 3 ++ test/images/nonroot/Dockerfile_windows | 18 +++++++++ test/images/redis/BASEIMAGE | 3 ++ test/images/redis/Dockerfile_windows | 33 ++++++++++++++++ test/images/redis/VERSION | 2 +- test/images/redis/redis.conf | 1 + test/images/sample-apiserver/BASEIMAGE | 3 ++ test/images/sample-apiserver/Dockerfile | 21 +--------- .../sample-apiserver/Dockerfile_windows | 28 +++++++++++++ test/images/sample-apiserver/Makefile | 37 ++++++++++++++++++ 15 files changed, 205 insertions(+), 21 deletions(-) create mode 100644 test/images/echoserver/Dockerfile_windows create mode 100644 test/images/jessie-dnsutils/Dockerfile_windows create mode 100644 test/images/nonroot/Dockerfile_windows create mode 100644 test/images/redis/Dockerfile_windows create mode 100644 test/images/sample-apiserver/Dockerfile_windows create mode 100644 test/images/sample-apiserver/Makefile diff --git a/build/dependencies.yaml b/build/dependencies.yaml index 72c97c5e65c..288cd5708b1 100644 --- a/build/dependencies.yaml +++ b/build/dependencies.yaml @@ -113,7 +113,7 @@ dependencies: version: v1.15.2-1 refPaths: - path: build/build-image/cross/VERSION - - path: test/images/sample-apiserver/Dockerfile + - path: test/images/sample-apiserver/Makefile match: k8s\.gcr\.io\/build-image\/kube-cross:v((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?) # Base images diff --git a/test/images/echoserver/BASEIMAGE b/test/images/echoserver/BASEIMAGE index 269c92ac3ad..82c59fd2470 100644 --- a/test/images/echoserver/BASEIMAGE +++ b/test/images/echoserver/BASEIMAGE @@ -3,3 +3,6 @@ linux/arm=arm32v6/nginx:1.15-alpine linux/arm64=arm64v8/nginx:1.15-alpine linux/ppc64le=ppc64le/nginx:1.15-alpine linux/s390x=s390x/nginx:1.15-alpine +windows/amd64/1809=REGISTRY/busybox:1.29-windows-amd64-1809 +windows/amd64/1903=REGISTRY/busybox:1.29-windows-amd64-1903 +windows/amd64/1909=REGISTRY/busybox:1.29-windows-amd64-1909 diff --git a/test/images/echoserver/Dockerfile_windows b/test/images/echoserver/Dockerfile_windows new file mode 100644 index 00000000000..2b1ba96259a --- /dev/null +++ b/test/images/echoserver/Dockerfile_windows @@ -0,0 +1,39 @@ +# Copyright 2020 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ARG BASEIMAGE +ARG REGISTRY + +# We're using a Linux image to unpack the archive, then we're copying it over to Windows. +FROM --platform=linux/amd64 alpine:3.6 as prep + +ADD https://openresty.org/download/openresty-1.13.6.2-win64.zip /openresty-win64.zip +RUN mkdir /openresty &&\ + unzip /openresty-win64.zip -d /openresty + +FROM $REGISTRY/windows-image-builder-helper:1.1-windows-amd64-1809 as helper +FROM $BASEIMAGE + +COPY --from=prep /openresty/openresty-1.13.6.2-win64 /openresty +COPY --from=helper /Windows/System32/vcruntime140.dll /Windows/System32/ +COPY --from=helper ["/Program Files/OpenSSL", "/Program Files/OpenSSL"] + +ENV PATH="C:\openresty\;C:\bin\;C:\curl\;C:\Windows\system32;C:\Windows;C:\Program Files\PowerShell;" + +ADD run.sh /openresty/run.sh +ADD nginx.conf /openresty/conf/nginx.conf +ADD template.lua /openresty/lua/template.lua + +EXPOSE 80 443 8080 8443 +ENTRYPOINT ["/bin/sh", "/openresty/run.sh"] diff --git a/test/images/jessie-dnsutils/BASEIMAGE b/test/images/jessie-dnsutils/BASEIMAGE index 329768b58c1..704e84e512b 100644 --- a/test/images/jessie-dnsutils/BASEIMAGE +++ b/test/images/jessie-dnsutils/BASEIMAGE @@ -3,3 +3,6 @@ linux/arm=arm32v7/debian:jessie linux/arm64=arm64v8/debian:jessie linux/ppc64le=ppc64le/debian:jessie linux/s390x=s390x/debian:jessie +windows/amd64/1809=REGISTRY/busybox:1.29-windows-amd64-1809 +windows/amd64/1903=REGISTRY/busybox:1.29-windows-amd64-1903 +windows/amd64/1909=REGISTRY/busybox:1.29-windows-amd64-1909 diff --git a/test/images/jessie-dnsutils/Dockerfile_windows b/test/images/jessie-dnsutils/Dockerfile_windows new file mode 100644 index 00000000000..3b41a1243a0 --- /dev/null +++ b/test/images/jessie-dnsutils/Dockerfile_windows @@ -0,0 +1,30 @@ +# Copyright 2020 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ARG BASEIMAGE + +# We're using a Linux image to unpack the archive, then we're copying it over to Windows. +FROM --platform=linux/amd64 alpine:3.6 as prep + +ADD https://github.com/coredns/coredns/releases/download/v1.5.0/coredns_1.5.0_windows_amd64.tgz /coredns.tgz +RUN tar -xzvf /coredns.tgz + +FROM e2eteam/busybox-helper:1.29.0 as busybox-helper +FROM $BASEIMAGE + +COPY --from=prep /coredns.exe /coredns.exe +COPY --from=busybox-helper /dig /dig + +# NOTE(claudiub): docker buildx sets the PATH env variable to a Linux-like PATH, which is not desirable. +ENV PATH="C:\dig\;C:\bin;C:\curl;C:\Windows\System32;C:\Windows;C:\Program Files\PowerShell;" diff --git a/test/images/nonroot/BASEIMAGE b/test/images/nonroot/BASEIMAGE index da1cc2e96a9..d21f5f08ac3 100644 --- a/test/images/nonroot/BASEIMAGE +++ b/test/images/nonroot/BASEIMAGE @@ -3,3 +3,6 @@ linux/arm=k8s.gcr.io/debian-base-arm:v1.0.0 linux/arm64=k8s.gcr.io/debian-base-arm64:v1.0.0 linux/ppc64le=k8s.gcr.io/debian-base-ppc64le:v1.0.0 linux/s390x=k8s.gcr.io/debian-base-s390x:v1.0.0 +windows/amd64/1809=mcr.microsoft.com/windows/nanoserver:1809 +windows/amd64/1903=mcr.microsoft.com/windows/nanoserver:1903 +windows/amd64/1909=mcr.microsoft.com/windows/nanoserver:1909 diff --git a/test/images/nonroot/Dockerfile_windows b/test/images/nonroot/Dockerfile_windows new file mode 100644 index 00000000000..b9f74b23d3e --- /dev/null +++ b/test/images/nonroot/Dockerfile_windows @@ -0,0 +1,18 @@ +# Copyright 2020 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ARG BASEIMAGE +FROM $BASEIMAGE + +USER ContainerUser diff --git a/test/images/redis/BASEIMAGE b/test/images/redis/BASEIMAGE index ad69ccfb016..cc7c45a7657 100644 --- a/test/images/redis/BASEIMAGE +++ b/test/images/redis/BASEIMAGE @@ -3,3 +3,6 @@ linux/arm=arm32v6/alpine:3.6 linux/arm64=arm64v8/alpine:3.6 linux/ppc64le=ppc64le/alpine:3.6 linux/s390x=s390x/alpine:3.6 +windows/amd64/1809=REGISTRY/busybox:1.29-windows-amd64-1809 +windows/amd64/1903=REGISTRY/busybox:1.29-windows-amd64-1903 +windows/amd64/1909=REGISTRY/busybox:1.29-windows-amd64-1909 diff --git a/test/images/redis/Dockerfile_windows b/test/images/redis/Dockerfile_windows new file mode 100644 index 00000000000..219bdcfcafc --- /dev/null +++ b/test/images/redis/Dockerfile_windows @@ -0,0 +1,33 @@ +# Copyright 2020 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ARG BASEIMAGE + +# We're using a Linux image to unpack the archive, then we're copying it over to Windows. +FROM --platform=linux/amd64 alpine:3.6 as prep + +ADD https://github.com/MSOpenTech/redis/releases/download/win-3.2.100/Redis-x64-3.2.100.zip /redis.zip +RUN mkdir /redis &&\ + unzip /redis.zip -d /redis + +FROM $BASEIMAGE + +COPY --from=prep /redis /redis + +COPY redis.conf /redis/redis.windows.conf + +EXPOSE 6379 +VOLUME C:/data + +CMD ["/redis/redis-server.exe", "/redis/redis.windows.conf"] diff --git a/test/images/redis/VERSION b/test/images/redis/VERSION index 9459d4ba2a0..89d706aee45 100644 --- a/test/images/redis/VERSION +++ b/test/images/redis/VERSION @@ -1 +1 @@ -1.1 +5.0.5-alpine diff --git a/test/images/redis/redis.conf b/test/images/redis/redis.conf index 2134f813e51..afbc658ee17 100644 --- a/test/images/redis/redis.conf +++ b/test/images/redis/redis.conf @@ -1,2 +1,3 @@ bind 0.0.0.0 dir /data +protected-mode no diff --git a/test/images/sample-apiserver/BASEIMAGE b/test/images/sample-apiserver/BASEIMAGE index 0b0e6ddd30a..08ae26e3512 100644 --- a/test/images/sample-apiserver/BASEIMAGE +++ b/test/images/sample-apiserver/BASEIMAGE @@ -3,3 +3,6 @@ linux/arm=arm32v6/alpine:3.8 linux/arm64=arm64v8/alpine:3.8 linux/ppc64le=ppc64le/alpine:3.8 linux/s390x=s390x/alpine:3.8 +windows/amd64/1809=mcr.microsoft.com/windows/nanoserver:1809 +windows/amd64/1903=mcr.microsoft.com/windows/nanoserver:1903 +windows/amd64/1909=mcr.microsoft.com/windows/nanoserver:1909 diff --git a/test/images/sample-apiserver/Dockerfile b/test/images/sample-apiserver/Dockerfile index 2ab6420e79e..37d2465087e 100644 --- a/test/images/sample-apiserver/Dockerfile +++ b/test/images/sample-apiserver/Dockerfile @@ -12,28 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -ARG BASEIMAGE -FROM --platform=linux/amd64 k8s.gcr.io/build-image/kube-cross:v1.15.2-1 as build_k8s_1_17_sample_apiserver - -ENV GOPATH /go -RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin -ENV PATH $GOPATH/bin:$PATH - - # The e2e aggregator test is designed to test ability to run sample-apiserver as an aggregated server. # see e2e test named "Should be able to support the 1.17 Sample API Server using the current Aggregator" -# Build v1.17.0 to ensure the current release supports a prior version of the sample apiserver -# Get without building to populate module cache -RUN GO111MODULE=on go get -d k8s.io/sample-apiserver@v0.17.0 -# Get with OS/ARCH-specific env to build -RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=BASEARCH go get k8s.io/sample-apiserver@v0.17.0 - -# for arm, go install uses go/bin/linux_arm, so just find the file and copy it to the root so -# we can copy it out from this throw away container image from a standard location -RUN find /go/bin -name sample-apiserver -exec cp {} / \; - +ARG BASEIMAGE FROM $BASEIMAGE -COPY --from=build_k8s_1_17_sample_apiserver /sample-apiserver /sample-apiserver +ADD sample-apiserver /sample-apiserver ENTRYPOINT ["/sample-apiserver"] diff --git a/test/images/sample-apiserver/Dockerfile_windows b/test/images/sample-apiserver/Dockerfile_windows new file mode 100644 index 00000000000..2b23dfa845c --- /dev/null +++ b/test/images/sample-apiserver/Dockerfile_windows @@ -0,0 +1,28 @@ +# Copyright 2020 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# The e2e aggregator test is designed to test ability to run sample-apiserver as an aggregated server. +# see e2e test named "Should be able to support the 1.17 Sample API Server using the current Aggregator" + +ARG BASEIMAGE +ARG REGISTRY +ARG OS_VERSION + +FROM --platform=linux/amd64 $REGISTRY/windows-servercore-cache:1.0-linux-amd64-$OS_VERSION as servercore-helper +FROM $BASEIMAGE + +COPY --from=servercore-helper /Windows/System32/netapi32.dll /Windows/System32/netapi32.dll +ADD sample-apiserver /sample-apiserver.exe + +ENTRYPOINT ["/sample-apiserver.exe"] diff --git a/test/images/sample-apiserver/Makefile b/test/images/sample-apiserver/Makefile new file mode 100644 index 00000000000..7a3932acc66 --- /dev/null +++ b/test/images/sample-apiserver/Makefile @@ -0,0 +1,37 @@ +# Copyright 2020 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +OS ?= linux +ARCH ?= amd64 +TARGET ?= $(CURDIR) +GOARM = 7 +GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export + +# Build v1.17.0 to ensure the current release supports a prior version of the sample apiserver +# Get without building to populate module cache +# Then, get with OS/ARCH-specific env to build +bin: + docker run --rm -it -v "${TARGET}:${TARGET}:Z" k8s.gcr.io/build-image/kube-cross:v1.15.2-1 \ + /bin/bash -c "\ + mkdir -p /go/src /go/bin && \ + GO111MODULE=on go get -d k8s.io/sample-apiserver@v0.17.0 && \ + GO111MODULE=on CGO_ENABLED=0 GOARM=${GOARM} GOOS=${OS} GOARCH=${ARCH} go get k8s.io/sample-apiserver@v0.17.0 && \ + find /go/bin -name sample-apiserver* -exec cp {} ${TARGET}/sample-apiserver \;" + # for arm, go install uses /go/bin/linux_arm, so just find the file and copy it to the + # root so we can copy it out from this throw away container image from a standard location. + # Windows executables have .exe extension, which is why we're searching sample-apiserver* + +.PHONY: bin