From 03a7bb49b1489ab63f082817256e606c3f809d3e Mon Sep 17 00:00:00 2001 From: Blaine Gardner Date: Tue, 9 May 2023 17:03:05 -0600 Subject: [PATCH] build & use multi-arch manifests for doc/crds Build multi-arch manifests (amd64 and arm64) for PR 'build`, 'master' images, and 'release' images. In the doc/crds/daemonset-install.yaml file, remove amd64-specific items, and use the 'latest' manifest that will autoselect the appropriate architecture for the system. Signed-off-by: Blaine Gardner --- .github/workflows/image-build.yml | 22 +++++++++++++ .github/workflows/image-push-master.yml | 30 ++++++++++++++++++ .github/workflows/image-push-release.yml | 39 ++++++++++++++++++++++++ doc/crds/daemonset-install.yaml | 6 ++-- hack/e2e-setup-kind-cluster.sh | 6 ++-- 5 files changed, 97 insertions(+), 6 deletions(-) diff --git a/.github/workflows/image-build.yml b/.github/workflows/image-build.yml index 8a3b1634c..e8b5461a5 100644 --- a/.github/workflows/image-build.yml +++ b/.github/workflows/image-build.yml @@ -58,3 +58,25 @@ jobs: tags: ghcr.io/${{ github.repository }}:latest-arm64 file: Dockerfile.arm64 platforms: linux/arm64 + + build-multi-arch: + name: Image build multi-arch + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build container image + uses: docker/build-push-action@v2 + with: + context: . + push: false + tags: ghcr.io/${{ github.repository }}:latest + file: Dockerfile + platforms: linux/amd64, linux/arm64 diff --git a/.github/workflows/image-push-master.yml b/.github/workflows/image-push-master.yml index ea5bfeb10..891a78f05 100644 --- a/.github/workflows/image-push-master.yml +++ b/.github/workflows/image-push-master.yml @@ -89,3 +89,33 @@ jobs: tags: ghcr.io/${{ github.repository }}:latest-arm64 file: Dockerfile.arm64 platforms: linux/arm64 + + push-multi-arch: + name: Image build multi-arch + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to Container Registry + if: github.repository_owner == 'k8snetworkplumbingwg' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build container image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ghcr.io/${{ github.repository }}:latest + file: Dockerfile + platforms: linux/amd64, linux/arm64 diff --git a/.github/workflows/image-push-release.yml b/.github/workflows/image-push-release.yml index e3159033f..085cc4652 100644 --- a/.github/workflows/image-push-release.yml +++ b/.github/workflows/image-push-release.yml @@ -79,3 +79,42 @@ jobs: ${{ steps.docker_meta.outputs.tags }}-arm64 file: Dockerfile platforms: linux/arm64 + + push-multi-arch: + name: Image push multi-arch + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to Container Registry + if: github.repository_owner == 'k8snetworkplumbingwg' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + images: ghcr.io/${{ github.repository }} + tag-latest: false + + - name: Push container image + if: github.repository_owner == 'k8snetworkplumbingwg' + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: | + ${{ steps.docker_meta.outputs.tags }} + file: Dockerfile + platforms: linux/amd64, linux/arm64 diff --git a/doc/crds/daemonset-install.yaml b/doc/crds/daemonset-install.yaml index 7fba9ec88..2c6ad832a 100644 --- a/doc/crds/daemonset-install.yaml +++ b/doc/crds/daemonset-install.yaml @@ -91,10 +91,8 @@ spec: app: whereabouts name: whereabouts spec: - hostNetwork: true + hostNetwork: true serviceAccountName: whereabouts - nodeSelector: - kubernetes.io/arch: amd64 tolerations: - operator: Exists effect: NoSchedule @@ -106,7 +104,7 @@ spec: - > SLEEP=false /install-cni.sh && /ip-control-loop -log-level debug - image: ghcr.io/k8snetworkplumbingwg/whereabouts:latest-amd64 + image: ghcr.io/k8snetworkplumbingwg/whereabouts:latest env: - name: NODENAME valueFrom: diff --git a/hack/e2e-setup-kind-cluster.sh b/hack/e2e-setup-kind-cluster.sh index c03d40ef1..db0fbedc9 100755 --- a/hack/e2e-setup-kind-cluster.sh +++ b/hack/e2e-setup-kind-cluster.sh @@ -26,7 +26,7 @@ KIND_CLUSTER_NAME="whereabouts" OCI_BIN="${OCI_BIN:-"docker"}" IMG_PROJECT="whereabouts" IMG_REGISTRY="ghcr.io/k8snetworkplumbingwg" -IMG_TAG="latest-amd64" +IMG_TAG="latest" IMG_NAME="$IMG_REGISTRY/$IMG_PROJECT:$IMG_TAG" create_cluster() { @@ -99,7 +99,9 @@ kind load image-archive --name "$KIND_CLUSTER_NAME" /tmp/whereabouts-img.tar echo "## install whereabouts" for file in "daemonset-install.yaml" "whereabouts.cni.cncf.io_ippools.yaml" "whereabouts.cni.cncf.io_overlappingrangeipreservations.yaml"; do - retry kubectl apply -f "$ROOT/doc/crds/$file" + # insert 'imagePullPolicy: Never' under the container 'image' so it is certain that the image used + # by the daemonset is the one loaded into KinD and not one pulled from a repo + sed '/ image:/a\ imagePullPolicy: Never' "$ROOT/doc/crds/$file" | retry kubectl apply -f - done retry kubectl wait -n kube-system --for=condition=ready -l app=whereabouts pod --timeout=$TIMEOUT_K8 echo "## done"