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.
This commit is contained in:
Claudiu Belu 2019-04-18 14:38:12 +00:00
parent 2046f4212a
commit 4dbb55fe85
15 changed files with 205 additions and 21 deletions

View File

@ -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

View File

@ -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

View File

@ -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"]

View File

@ -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

View File

@ -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;"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"]

View File

@ -1 +1 @@
1.1
5.0.5-alpine

View File

@ -1,2 +1,3 @@
bind 0.0.0.0
dir /data
protected-mode no

View File

@ -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

View File

@ -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"]

View File

@ -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"]

View File

@ -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