mirror of
https://github.com/vee1e/KubeArmor.git
synced 2026-09-01 10:18:29 +00:00
add cross arch build feature
Signed-off-by: Achref ben saad <achref@accuknox.com>
This commit is contained in:
parent
1a6fbf4727
commit
98c73316cf
8 changed files with 105 additions and 25 deletions
|
|
@ -1,2 +1,3 @@
|
|||
# These object files are compiled at runtime in init container
|
||||
**/BPF/*.o
|
||||
Dockerfile
|
||||
54
.github/workflows/ci-controllers-release.yml
vendored
54
.github/workflows/ci-controllers-release.yml
vendored
|
|
@ -1,5 +1,4 @@
|
|||
name: ci-controllers-release
|
||||
|
||||
name: ci-test-controllers
|
||||
|
||||
on:
|
||||
push:
|
||||
|
|
@ -8,6 +7,9 @@ on:
|
|||
paths:
|
||||
- "pkg/**"
|
||||
|
||||
env:
|
||||
PLATFORM: linux/amd64,linux/arm64/v8
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Check what controllers were updated
|
||||
|
|
@ -30,9 +32,9 @@ jobs:
|
|||
- 'pkg/KubeArmorHostPolicy/**'
|
||||
policy:
|
||||
- 'pkg/KubeArmorPolicy/**'
|
||||
|
||||
|
||||
annotation-controller-release:
|
||||
name: Build & push annotation controller
|
||||
name: Build & Push annotation controller
|
||||
needs: check
|
||||
defaults:
|
||||
run:
|
||||
|
|
@ -47,17 +49,25 @@ jobs:
|
|||
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with:
|
||||
platforms: $PLATFORM
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_AUTHTOK }}
|
||||
|
||||
- name: Build & push annotation controller
|
||||
run: make docker-build docker-push TAG=latest
|
||||
|
||||
- name: Build & Push annotation controller
|
||||
run: PLATFORM=$PLATFORM make docker-buildx TAG=latest
|
||||
|
||||
hostpolicy-controller-release:
|
||||
name: Build & push hostpolicy controller
|
||||
name: Build & Push hostpolicy controller
|
||||
needs: check
|
||||
defaults:
|
||||
run:
|
||||
|
|
@ -72,17 +82,25 @@ jobs:
|
|||
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with:
|
||||
platforms: $PLATFORM
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_AUTHTOK }}
|
||||
|
||||
- name: Build & push hostpolicy controller
|
||||
run: make docker-build docker-push TAG=latest
|
||||
- name: Build & Push hostpolicy controller
|
||||
run: PLATFORM=$PLATFORM make docker-buildx TAG=latest
|
||||
|
||||
policy-controller-release:
|
||||
name: Build & push policy controller
|
||||
name: Build & Push policy controller
|
||||
needs: check
|
||||
defaults:
|
||||
run:
|
||||
|
|
@ -97,13 +115,19 @@ jobs:
|
|||
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with:
|
||||
platforms: $PLATFORM
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_AUTHTOK }}
|
||||
|
||||
- name: Build & push policy controller
|
||||
run: make docker-build docker-push TAG=latest
|
||||
|
||||
|
||||
- name: Build & Push policy controller
|
||||
run: PLATFORM=$PLATFORM make docker-buildx TAG=latest
|
||||
|
|
|
|||
20
.github/workflows/ci-latest-release.yml
vendored
20
.github/workflows/ci-latest-release.yml
vendored
|
|
@ -10,11 +10,15 @@ on:
|
|||
- "tests/**"
|
||||
- "protobuf/**"
|
||||
- ".github/workflows/ci-latest-release.yml"
|
||||
- "!STABLE-RELEASE"
|
||||
|
||||
create:
|
||||
branches:
|
||||
- "v*"
|
||||
|
||||
env:
|
||||
PLATFORM: linux/amd64,linux/arm64/v8
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Create KubeArmor latest release
|
||||
|
|
@ -68,6 +72,14 @@ jobs:
|
|||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_AUTHTOK }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with:
|
||||
platforms: $PLATFORM
|
||||
|
||||
- name: Push KubeArmor images to Docker
|
||||
run: ./KubeArmor/build/push_kubearmor.sh ${{ steps.vars.outputs.tag }}
|
||||
|
||||
|
|
@ -101,6 +113,14 @@ jobs:
|
|||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_AUTHTOK }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with:
|
||||
platforms: $PLATFORM
|
||||
|
||||
- name: Push the stable version of KubeArmor to Docker Hub
|
||||
if: steps.match.outputs.tag == 'true'
|
||||
run: ./KubeArmor/build/push_kubearmor.sh stable
|
||||
|
|
|
|||
19
.github/workflows/ci-stable-release.yml
vendored
19
.github/workflows/ci-stable-release.yml
vendored
|
|
@ -7,6 +7,9 @@ on:
|
|||
- "STABLE-RELEASE"
|
||||
- ".github/workflows/ci-stable-release.yml"
|
||||
|
||||
env:
|
||||
PLATFORM: linux/amd64,linux/arm64/v8
|
||||
|
||||
jobs:
|
||||
push-stable-version:
|
||||
name: Create KubeArmor stable release
|
||||
|
|
@ -20,19 +23,19 @@ jobs:
|
|||
with:
|
||||
go-version: v1.18
|
||||
|
||||
- name: Pull a specific version of KubeArmor from Docker Hub
|
||||
run: |
|
||||
value=`cat STABLE-RELEASE`
|
||||
docker pull docker.io/kubearmor/kubearmor:$value
|
||||
docker pull docker.io/kubearmor/kubearmor-init:latest
|
||||
docker image tag kubearmor/kubearmor:$value kubearmor/kubearmor:stable
|
||||
docker image tag kubearmor/kubearmor-init:latest kubearmor/kubearmor-init:stable
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_AUTHTOK }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with:
|
||||
platforms: $PLATFORM
|
||||
|
||||
- name: Push the stable version of KubeArmor to Docker Hub
|
||||
run: ./KubeArmor/build/push_kubearmor.sh stable
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
[[ "$REPO" == "" ]] && REPO="kubearmor/kubearmor"
|
||||
|
||||
[[ "$PLATFORMS" == "" ]] && PLATFORMS="linux/amd64"
|
||||
|
||||
VERSION=latest
|
||||
|
||||
# check version
|
||||
|
|
@ -11,16 +13,37 @@ if [ ! -z $1 ]; then
|
|||
VERSION="$1"
|
||||
fi
|
||||
|
||||
realpath() {
|
||||
CURR=$PWD
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
LINK=$(readlink "$(basename "$0")")
|
||||
|
||||
while [ "$LINK" ]; do
|
||||
cd "$(dirname "$LINK")"
|
||||
LINK=$(readlink "$(basename "$1")")
|
||||
done
|
||||
|
||||
REALPATH="$PWD/$(basename "$1")"
|
||||
echo "$REALPATH"
|
||||
|
||||
cd $CURR
|
||||
}
|
||||
|
||||
ARMOR_HOME=`dirname $(realpath "$0")`/..
|
||||
cd $ARMOR_HOME/build
|
||||
pwd
|
||||
|
||||
# push $REPO
|
||||
echo "[INFO] Pushing $REPO:$VERSION"
|
||||
docker push $REPO:$VERSION
|
||||
cd $ARMOR_HOME/..; docker buildx build --platform $PLATFORMS -t $REPO:$VERSION --push .
|
||||
|
||||
[[ $? -ne 0 ]] && echo "[FAILED] Failed to push $REPO:$VERSION" && exit 1
|
||||
echo "[PASSED] Pushed $REPO:$VERSION"
|
||||
|
||||
# push $REPO-init
|
||||
echo "[INFO] Pushing $REPO-init:$VERSION"
|
||||
docker push $REPO-init:$VERSION
|
||||
cd $ARMOR_HOME/..; docker buildx build --platform $PLATFORMS -t $REPO-init:$VERSION --push .
|
||||
|
||||
[[ $? -ne 0 ]] && echo "[FAILED] Failed to push $REPO-init:$VERSION" && exit 1
|
||||
echo "[PASSED] Pushed $REPO-init:$VERSION"
|
||||
|
|
|
|||
|
|
@ -72,6 +72,9 @@ run: manifests generate fmt vet ## Run a controller from your host.
|
|||
docker-build: build ## Build docker image with the manager.
|
||||
docker build -t ${IMG}:${TAG} -t ${IMG}:latest .
|
||||
|
||||
docker-buildx: build ## Build docker image with the manager multiple archs.
|
||||
docker buildx build --platform ${PLATFORMS} --push -t ${IMG}:${TAG} -t ${IMG}:latest .
|
||||
|
||||
docker-push: ## Push docker image with the manager.
|
||||
docker push ${IMG}:${TAG}
|
||||
docker push ${IMG}:latest
|
||||
|
|
|
|||
|
|
@ -75,6 +75,9 @@ generate: controller-gen
|
|||
docker-build:
|
||||
docker build -t ${IMG}:${TAG} -t ${IMG}:latest .
|
||||
|
||||
docker-buildx: build ## Build docker image with the manager multiple archs.
|
||||
docker buildx build --platform ${PLATFORMS} --push -t ${IMG}:${TAG} -t ${IMG}:latest .
|
||||
|
||||
# Push the docker image
|
||||
docker-push:
|
||||
docker push ${IMG}:${TAG}
|
||||
|
|
|
|||
|
|
@ -75,6 +75,9 @@ generate: controller-gen
|
|||
docker-build:
|
||||
docker build -t ${IMG}:${TAG} -t ${IMG}:latest .
|
||||
|
||||
docker-buildx: build ## Build docker image with the manager multiple archs.
|
||||
docker buildx build --platform ${PLATFORMS} --push -t ${IMG}:${TAG} -t ${IMG}:latest .
|
||||
|
||||
# Push the docker image
|
||||
docker-push:
|
||||
docker push ${IMG}:${TAG}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue