From b7ab0cbc9ed88c5104948942936937c9321d7588 Mon Sep 17 00:00:00 2001 From: Alan Peng Date: Tue, 13 Dec 2022 23:59:06 -0500 Subject: [PATCH] Build multi-arch image --- .circleci/config.yml | 74 ++++++++++++++++++--------- .gitlab-ci.yml | 24 --------- build-images.sh | 56 -------------------- gitlab-ci-template.yml | 113 ----------------------------------------- kubeadm.conf.old | 23 --------- 5 files changed, 50 insertions(+), 240 deletions(-) delete mode 100644 .gitlab-ci.yml delete mode 100755 build-images.sh delete mode 100644 gitlab-ci-template.yml delete mode 100644 kubeadm.conf.old diff --git a/.circleci/config.yml b/.circleci/config.yml index 004435b..09e0467 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,69 +1,95 @@ jobs: - build-branches-x86: + build-branches-amd64: machine: true steps: - checkout - run: - name: Build a container image + name: Build an amd64 container image command: | - docker build -f Dockerfile.amd64 -t wise2c/kubeadm-version:$CIRCLE_BRANCH . - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD - docker push wise2c/kubeadm-version:$CIRCLE_BRANCH - docker run --rm --name=kubeadm-version wise2c/kubeadm-version:$CIRCLE_BRANCH kubeadm config images list + docker build -f Dockerfile.amd64 -t wise2c/kubeadm-version:amd64-$CIRCLE_BRANCH . + # docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + # docker push wise2c/kubeadm-version:amd64-$CIRCLE_BRANCH + docker run --rm --name=kubeadm-version wise2c/kubeadm-version:amd64-$CIRCLE_BRANCH kubeadm config images list build-tags-x86: machine: true steps: - checkout - run: - name: Build a container image + name: Build an amd64 container image command: | - docker build -f Dockerfile.amd64 -t wise2c/kubeadm-version:$CIRCLE_TAG . + docker build -f Dockerfile.amd64 -t wise2c/kubeadm-version:amd64-$CIRCLE_TAG . docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD - docker push wise2c/kubeadm-version:$CIRCLE_TAG - docker run --rm --name=kubeadm-version wise2c/kubeadm-version:$CIRCLE_TAG kubeadm config images list + docker push wise2c/kubeadm-version:amd64-$CIRCLE_TAG + docker run --rm --name=kubeadm-version wise2c/kubeadm-version:amd64-$CIRCLE_TAG kubeadm config images list - build-branches-arm: + build-branches-aarch64: machine: true resource_class: arm.medium steps: - checkout - run: - name: Build a container image + name: Build an aarch64 container image command: | - docker build -f Dockerfile.aarch64 -t wise2c/kubeadm-version-arm:$CIRCLE_BRANCH . + docker build -f Dockerfile.aarch64 -t wise2c/kubeadm-version:aarch64-$CIRCLE_BRANCH . docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD - docker push wise2c/kubeadm-version-arm:$CIRCLE_BRANCH - docker run --rm --name=kubeadm-version wise2c/kubeadm-version-arm:$CIRCLE_BRANCH kubeadm config images list + docker push wise2c/kubeadm-version:aarch64-$CIRCLE_BRANCH + docker run --rm --name=kubeadm-version wise2c/kubeadm-version:aarch64-$CIRCLE_BRANCH kubeadm config images list - build-tags-arm: + build-tags-aarch64: resource_class: arm.medium machine: true steps: - checkout - run: - name: Build a container image + name: Build an aarch64 container image + command: | + docker build -f Dockerfile.aarch64 -t wise2c/kubeadm-version:aarch64-$CIRCLE_TAG . + docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + docker push wise2c/kubeadm-version:aarch64-$CIRCLE_TAG + docker run --rm --name=kubeadm-version wise2c/kubeadm-version:aarch64-$CIRCLE_TAG kubeadm config images list + + build-branches-multi-arch: + machine: true + steps: + - run: + name: Build a multi-arch container image command: | - docker build -f Dockerfile.aarch64 -t wise2c/kubeadm-version-arm:$CIRCLE_TAG . + docker manifest create wise2c/kubeadm-version:$CIRCLE_BRANCH wise2c/kubeadm-version:amd64-$CIRCLE_BRANCH wise2c/kubeadm-version:aarch64-$CIRCLE_BRANCH + docker manifest annotate wise2c/kubeadm-version:$CIRCLE_BRANCH wise2c/kubeadm-version:amd64-$CIRCLE_BRANCH --os linux --arch amd64 + docker manifest annotate wise2c/kubeadm-version:$CIRCLE_BRANCH wise2c/kubeadm-version:aarch64-$CIRCLE_BRANCH --os linux --arch arm64 docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD - docker push wise2c/kubeadm-version-arm:$CIRCLE_TAG - docker run --rm --name=kubeadm-version wise2c/kubeadm-version-arm:$CIRCLE_TAG kubeadm config images list + docker manifest push wise2c/kubeadm-version:$CIRCLE_BRANCH + docker run --rm --name=kubeadm-version wise2c/kubeadm-version:$CIRCLE_BRANCH kubeadm config images list + + build-tags-multi-arch: + machine: true + steps: + - run: + name: Build a multi-arch container image + command: | + docker manifest create wise2c/kubeadm-version:$CIRCLE_TAG wise2c/kubeadm-version:amd64-$CIRCLE_TAG wise2c/kubeadm-version:aarch64-$CIRCLE_TAG + docker manifest annotate wise2c/kubeadm-version:$CIRCLE_TAG wise2c/kubeadm-version:amd64-$CIRCLE_TAG --os linux --arch amd64 + docker manifest annotate wise2c/kubeadm-version:$CIRCLE_TAG wise2c/kubeadm-version:aarch64-$CIRCLE_TAG --os linux --arch arm64 + docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + docker manifest push wise2c/kubeadm-version:$CIRCLE_TAG + docker run --rm --name=kubeadm-version wise2c/kubeadm-version:$CIRCLE_TAG kubeadm config images list workflows: version: 2 build-for-branches: jobs: - - build-branches-x86 - - build-branches-arm + - build-branches-amd64 + - build-branches-aarch64 build-for-tags: jobs: - - build-tags-x86: + - build-tags-amd64: filters: tags: only: /^v.*/ branches: ignore: /.*/ - - build-tags-arm: + - build-tags-aarch64: filters: tags: only: /^v.*/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 2290174..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,24 +0,0 @@ -stages: -- build - -buildkitd: - stage: build - - services: - - alias: buildkitd - name: moby/buildkit:rootless - command: - - "--oci-worker-no-process-sandbox" - - "--addr" - - "tcp://0.0.0.0:1234" - variables: - BUILDKIT_HOST: tcp://buildkitd:1234 - - image: - name: moby/buildkit:rootless - entrypoint: [ "sh", "-c" ] - script: - - sh build-images.sh - tags: - - docker - when: always diff --git a/build-images.sh b/build-images.sh deleted file mode 100755 index ce6a265..0000000 --- a/build-images.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh - -# kudos https://dev.to/zeerorg/build-multi-arch-docker-images-on-travis-5428 - -docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD - -# Build for amd64 and push -buildctl build --frontend dockerfile.v0 \ - --local dockerfile=. \ - --local context=. \ - --output type=image,name=wise2c/kubeadm-version:v1.20.5-amd64,push=true \ - --opt platform=linux/amd64 \ - --opt filename=./Dockerfile.amd64 - - -# Build for arm64 and push -buildctl build --frontend dockerfile.v0 \ - --local dockerfile=. \ - --local context=. \ - --output type=image,name=wise2c/kubeadm-version:v1.20.5-arm64,push=true \ - --opt platform=linux/arm64 \ - --opt filename=./Dockerfile.aarch64 - - -export DOCKER_CLI_EXPERIMENTAL=enabled - -# Create manifest list and push that -# 1.20.5 -docker manifest create wise2c/kubeadm-version:v1.20.5 \ - wise2c/kubeadm-version:v1.20.5-amd64 \ - wise2c/kubeadm-version:v1.20.5-arm64 - -docker manifest annotate wise2c/kubeadm-version:v1.20.5 wise2c/kubeadm-version:v1.20.5-arm64 --arch arm64 -docker manifest annotate wise2c/kubeadm-version:v1.20.5 wise2c/kubeadm-version:v1.20.5-amd64 --arch amd64 - -docker manifest push wise2c/kubeadm-version:v1.20.5 - -# latest -docker pull wise2c/kubeadm-version:v1.20.5 -docker pull wise2c/kubeadm-version:v1.20.5-amd64 -docker pull wise2c/kubeadm-version:v1.20.5-arm64 -docker tag wise2c/kubeadm-version:v1.20.5 wise2c/kubeadm-version:latest -docker tag wise2c/kubeadm-version:v1.20.5-amd64 wise2c/kubeadm-version:latest-amd64 -docker tag wise2c/kubeadm-version:v1.20.5-arm64 wise2c/kubeadm-version:latest-arm64 -docker push wise2c/kubeadm-version:latest -docker push wise2c/kubeadm-version:latest-arm64 -docker push wise2c/kubeadm-version:latest-amd64 - -docker manifest create wise2c/kubeadm-version:latest \ - wise2c/kubeadm-version:latest-amd64 \ - wise2c/kubeadm-version:latest-arm64 - -docker manifest annotate wise2c/kubeadm-version:latest wise2c/kubeadm-version:latest-arm64 --arch arm64 -docker manifest annotate wise2c/kubeadm-version:latest wise2c/kubeadm-version:latest-amd64 --arch amd64 - -docker manifest push wise2c/kubeadm-version:latest diff --git a/gitlab-ci-template.yml b/gitlab-ci-template.yml deleted file mode 100644 index b690f47..0000000 --- a/gitlab-ci-template.yml +++ /dev/null @@ -1,113 +0,0 @@ -variables: - CI_BUILD_IMAGE: "registry.gitlab.com/ericvh/docker-buildx-qemu" - -.build: - image: $CI_BUILD_IMAGE - stage: build - services: - - name: docker:dind - entrypoint: ["env", "-u", "DOCKER_HOST"] - command: ["dockerd-entrypoint.sh"] - variables: - DOCKER_HOST: tcp://docker:2375/ - DOCKER_DRIVER: overlay2 - # See https://github.com/docker-library/docker/pull/166 - DOCKER_TLS_CERTDIR: "" - retry: 2 - before_script: - - | - if [[ -z "$CI_COMMIT_TAG" ]]; then - export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG} - export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_SHA} - else - export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE} - export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_TAG} - fi - - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY - -build:buildx-master: - extends: .build - only: - refs: - - master - variables: - - $CI_BUILDX_ARCHS - script: - # Use docker-container driver to allow useful features (push/multi-platform) - - update-binfmts --enable # Important: Ensures execution of other binary formats is enabled in the kernel - - docker buildx create --driver docker-container --use - - docker buildx inspect --bootstrap - - docker buildx ls - - docker buildx build --platform $CI_BUILDX_ARCHS --progress plain --pull -t "$CI_REGISTRY_IMAGE" --push . - -build:buildx: - extends: .build - only: - variables: - - $CI_BUILDX_ARCHS - except: - refs: - - master - script: - - update-binfmts --enable # Important: Ensures execution of other binary formats is enabled in the kernel - - docker buildx create --driver docker-container --use - - docker buildx inspect --bootstrap - - docker buildx ls - - docker buildx build --platform $CI_BUILDX_ARCHS --progress plain --pull -t "$CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG" --push . - -# disable build:armv7 for now since it seems to have an issue with dind -.build:arm: - image: docker:dind - extends: .build - only: - variables: - - $CI_BUILD_ARM - except: - variables: - - $CI_BUILDX_ARCHS - tags: - - arm - script: - - docker build -t "$CI_APPLICATION_REPOSITORY/arm:$CI_APPLICATION_TAG" -f Dockerfile.armhf . - - docker push "$CI_APPLICATION_REPOSITORY/arm:$CI_APPLICATION_TAG" - -build:arm64: - extends: .build - only: - variables: - - $CI_BUILD_ARM64 - except: - variables: - - $CI_BUILDX_ARCHS - tags: - - arm64 - - script: - - docker build -t "$CI_APPLICATION_REPOSITORY/arm64:$CI_APPLICATION_TAG" -f Dockerfile.aarch64 . - - docker push "$CI_APPLICATION_REPOSITORY/arm64:$CI_APPLICATION_TAG" - -build:amd64: - extends: .build - except: - variables: - - $CI_AMD64_DISABLED - - $CI_BUILDX_ARCHS - script: - - docker build -t "$CI_APPLICATION_REPOSITORY/amd64:$CI_APPLICATION_TAG" -f Dockerfile.amd64 . - - docker push "$CI_APPLICATION_REPOSITORY/amd64:$CI_APPLICATION_TAG" - -build:manifest: - extends: .build - stage: deploy - except: - variables: - - $CI_BUILDX_ARCHS - script: - - echo "Checking amd86 build..." && [[ -z $CI_AMD64_DISABLE ]] && echo "found" && export CI_MANIFEST_LIST="$CI_APPLICATION_REPOSITORY/amd64:$CI_APPLICATION_TAG" - - echo "Checking arm build..." && [[ $CI_BUILD_ARM ]] && echo "found" && export CI_MANIFEST_LIST="$CI_MANIFEST_LIST $CI_APPLICATION_REPOSITORY/arm:$CI_APPLICATION_TAG" - - echo "Checking arm64 build..." && [[ $CI_BUILD_ARM64 ]] && echo "found" && export CI_MANIFEST_LIST="$CI_MANIFEST_LIST $CI_APPLICATION_REPOSITORY/arm64:$CI_APPLICATION_TAG" - - export DOCKER_CLI_EXPERIMENTAL=enabled - - echo $CI_MANIFEST_LIST - - docker manifest create $CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG $CI_MANIFEST_LIST && docker manifest push $CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG - - docker manifest create $CI_APPLICATION_REPOSITORY:latest $CI_MANIFEST_LIST && docker manifest push $CI_APPLICATION_REPOSITORY:latest - - echo "Checking master" && [[ $CI_COMMIT_REF_NAME == "master" ]] && docker manifest create $CI_REGISTRY_IMAGE:latest $CI_MANIFEST_LIST && docker manifest push $CI_REGISTRY_IMAGE:latest diff --git a/kubeadm.conf.old b/kubeadm.conf.old deleted file mode 100644 index 04dcb3c..0000000 --- a/kubeadm.conf.old +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: kubeadm.k8s.io/v1alpha1 -kind: MasterConfiguration -etcd: - endpoints: - - http://192.168.9.11:2379 - - http://192.168.9.12:2379 - - http://192.168.9.13:2379 -networking: - podSubnet: 10.244.0.0/16 -kubernetesVersion: v1.12.0 -token: 904250.ab14566918c0703b -tokenTTL: 0s -apiServerExtraArgs: - apiserver-count: '3' - runtime-config: batch/v2alpha1=true - feature-gates: LocalStorageCapacityIsolation=true -controllerManagerExtraArgs: - feature-gates: LocalStorageCapacityIsolation=true -schedulerExtraArgs: - feature-gates: LocalStorageCapacityIsolation=true -apiServerCertSANs: - - 192.168.9.30 -imageRepository: 192.168.9.20/library