Skip to content

Commit

Permalink
Merge pull request #973 from achrefbensaad/update-ci-arm
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankurk99 committed Nov 9, 2022
2 parents 7785f53 + 98c7331 commit ef0d8aa
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 25 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# These object files are compiled at runtime in init container
**/BPF/*.o
Dockerfile
54 changes: 39 additions & 15 deletions .github/workflows/ci-controllers-release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: ci-controllers-release

name: ci-test-controllers

on:
push:
Expand All @@ -8,6 +7,9 @@ on:
paths:
- "pkg/**"

env:
PLATFORM: linux/amd64,linux/arm64/v8

jobs:
check:
name: Check what controllers were updated
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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 changes: 20 additions & 0 deletions .github/workflows/ci-latest-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}

Expand Down Expand Up @@ -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 changes: 11 additions & 8 deletions .github/workflows/ci-stable-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
27 changes: 25 additions & 2 deletions KubeArmor/build/push_kubearmor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,46 @@

[[ "$REPO" == "" ]] && REPO="kubearmor/kubearmor"

[[ "$PLATFORMS" == "" ]] && PLATFORMS="linux/amd64"

VERSION=latest

# check version
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"
Expand Down
3 changes: 3 additions & 0 deletions pkg/KubeArmorAnnotation/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions pkg/KubeArmorHostPolicy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
3 changes: 3 additions & 0 deletions pkg/KubeArmorPolicy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit ef0d8aa

Please sign in to comment.