Skip to content

Commit

Permalink
Add Windows support for toolbox image (#27)
Browse files Browse the repository at this point in the history
We add Windows images to the antrea/toolbox manifest (for both the 1809
and ltsc2022 Windows nanoserver versions).

The Windows image is based directly on K8s pause image. It includes
wincat, pause, and of course everything included by default in the
nanoserver image (such as ping).

In the future, we may want to install additional utilities in the
Windows image.

Because we share the same versioning between Linux and Windows, the
toolbox version is bumped up to 1.3.

Fixes #26

Signed-off-by: Antonin Bas <[email protected]>
  • Loading branch information
antoninbas authored Jan 30, 2024
1 parent 9121bda commit c164cf8
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 8 deletions.
85 changes: 78 additions & 7 deletions .github/workflows/docker_update_toolbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,42 @@ on:
paths:
- 'images/toolbox/**'

env:
REGISTRY_IMAGE: "antrea/toolbox"

jobs:
build:
get-docker-tag:
runs-on: ubuntu-latest
steps:
- name: Check-out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set docker tag
- name: Get docker tag
id: get-outputs
working-directory: images/toolbox
run: |
version=$(head -n 1 VERSION)
version_update_sha=$(git log -n 1 --pretty=format:%H -- VERSION)
rev=$(git rev-list --count ${version_update_sha}..HEAD -- .)
echo "version=${version}" >> $GITHUB_ENV
echo "rev=${rev}" >> $GITHUB_ENV
echo "docker_tag=${version}-${rev}" >> $GITHUB_ENV
echo "version=${version}" >> $GITHUB_OUTPUT
echo "rev=${rev}" >> $GITHUB_OUTPUT
echo "docker_tag=${version}-${rev}" >> $GITHUB_OUTPUT
outputs:
version: ${{ steps.get-outputs.outputs.version }}
rev: ${{ steps.get-outputs.outputs.rev }}
docker_tag: ${{ steps.get-outputs.outputs.docker_tag }}

build-linux:
runs-on: ubuntu-latest
needs: get-docker-tag
env:
DOCKER_TAG: ${{ needs.get-docker-tag.outputs.docker_tag }}
steps:
- name: Check-out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand All @@ -41,11 +60,63 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
id: build
uses: docker/build-push-action@v5
with:
context: images/toolbox
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: ${{ github.repository == 'antrea-io/image-utils' && github.event_name != 'pull_request' }}
# first tag should be immutable, others are rolling tags
tags: antrea/toolbox:${{ env.docker_tag }},antrea/toolbox:${{ env.version }},antrea/toolbox:latest
tags: ${{ env.REGISTRY_IMAGE }}:${{ env.DOCKER_TAG }}-linux
no-cache: true

build-windows:
runs-on: windows-latest
needs: get-docker-tag
env:
DOCKER_TAG: ${{ needs.get-docker-tag.outputs.docker_tag }}
steps:
- name: Check-out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build Docker images
shell: bash
run: |
docker build -t ${REGISTRY_IMAGE}:${DOCKER_TAG}-windows-ltsc2022 -f images/toolbox/Dockerfile-windows --build-arg WINDOWS_VERSION=ltsc2022 images/toolbox
docker build -t ${REGISTRY_IMAGE}:${DOCKER_TAG}-windows-1809 -f images/toolbox/Dockerfile-windows --build-arg WINDOWS_VERSION=1809 images/toolbox
- name: Login to DockerHub
if: ${{ github.repository == 'antrea-io/image-utils' && github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Create and push manifest list
if: ${{ github.repository == 'antrea-io/image-utils' && github.event_name != 'pull_request' }}
shell: bash
run: |
docker push ${REGISTRY_IMAGE}:${DOCKER_TAG}-windows-ltsc2022
docker push ${REGISTRY_IMAGE}:${DOCKER_TAG}-windows-1809
docker manifest create ${REGISTRY_IMAGE}:${DOCKER_TAG}-windows ${REGISTRY_IMAGE}:${DOCKER_TAG}-windows-ltsc2022 ${REGISTRY_IMAGE}:${DOCKER_TAG}-windows-1809
docker manifest push ${REGISTRY_IMAGE}:${DOCKER_TAG}-windows
manifest:
runs-on: ubuntu-latest
if: ${{ github.repository == 'antrea-io/image-utils' && github.event_name != 'pull_request' }}
needs: [get-docker-tag, build-linux, build-windows]
env:
DOCKER_CLI_EXPERIMENTAL: enabled
DOCKER_TAG: ${{ needs.get-docker-tag.outputs.docker_tag }}
VERSION: ${{ needs.get-docker-tag.outputs.version }}
steps:
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Create and push manifest list
run: |
# first tag should be immutable, others are rolling tags
docker buildx imagetools create -t ${REGISTRY_IMAGE}:${DOCKER_TAG} -t ${REGISTRY_IMAGE}:${VERSION} -t ${REGISTRY_IMAGE}:latest ${REGISTRY_IMAGE}:${DOCKER_TAG}-linux ${REGISTRY_IMAGE}:${DOCKER_TAG}-windows
- name: Inspect manifest list
run: |
docker buildx imagetools inspect ${REGISTRY_IMAGE}:${DOCKER_TAG}
34 changes: 34 additions & 0 deletions images/toolbox/Dockerfile-windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2024 Antrea 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.

# Should be 1809 or ltsc2022
ARG WINDOWS_VERSION

# See https://kubernetes.io/docs/concepts/windows/intro/#pause-container
# Unlike the image from registry.k8s.io, there are also different named tags for different OS
# versions, so we have more control.
FROM mcr.microsoft.com/oss/kubernetes/pause:3.9-windows-${WINDOWS_VERSION}-amd64

LABEL maintainer="Antrea <[email protected]>"
LABEL description="A Docker image with useful tools (for networking) based on the K8s pause image"

# We do not add any tools to the image at the moment.
# The image comes with pause + wincat + anything included by default in the nanoserver base image.

COPY VERSION /VERSION

# Reset entrypoint
ENTRYPOINT []

CMD ["/pause.exe"]
1 change: 1 addition & 0 deletions images/toolbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ Here is a changelog for the different versions of this image:
| 1.0 | Initial version. |
| 1.1 | Use pause as the default command. |
| 1.2 | Add netperf to image. |
| 1.3 | Add Windows support. |
2 changes: 1 addition & 1 deletion images/toolbox/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2
1.3

0 comments on commit c164cf8

Please sign in to comment.