Skip to content

Commit

Permalink
Merge pull request bpfman#1158 from Billy99/billy99-mv-oper-images
Browse files Browse the repository at this point in the history
multiarch: Move multiarch building to bpfman-operator repo
  • Loading branch information
mergify[bot] authored Jun 17, 2024
2 parents 2bf6bec + cf054f7 commit fecff25
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 212 deletions.
159 changes: 9 additions & 150 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,81 +272,43 @@ jobs:
filename: linux-x86_64
- arch: arm64
filename: linux-arm64
# - arch: ppc64le
# filename: linux-ppc64le
# - arch: s390x
# filename: linux-s390x
- arch: ppc64le
filename: linux-ppc64le
- arch: s390x
filename: linux-s390x
runs-on: ubuntu-latest
# k8s codegen requires this to be set
env:
GOPATH: ${{ github.workspace }}
defaults:
run:
## For us to run the controller-gen generate commands from within
## github actions the package name MUST match the directory layout
## (i.e `GOPATH/src/github.com/bpfman/bpfman`). Otherwise when
## running `make generate` generated code is deposited at
## `home/runner/work/bpfman/bpfman/bpfman-operator/PKG_NAME` instead
## of in `home/runner/work/bpfman/bpfman/bpfman-operator/pkg/client/...`.
## This is annoying and gross but cannot be resolved until
## https://github.com/kubernetes/kubernetes/issues/86753 is properly
## addressed.
working-directory: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman/bpfman-operator
steps:
- name: Checkout bpfman
uses: actions/checkout@v4
with:
path: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman

- name: Install go
uses: actions/setup-go@v5
with:
# prettier-ignore
## `make verify` failing on 1.22, so leave at 1.21 until issue determined.
go-version: '1.21' # yamllint disable-line rule:quoted-strings
go-version: '1.22' # yamllint disable-line rule:quoted-strings

- name: Go mod check
# Only need to run go mod once, so just pick one of the arch to run on.
if: ${{ matrix.arch.arch == 'amd64' }}
run: |
go mod tidy
git diff --exit-code ../go.mod ../go.sum
git diff --exit-code go.mod go.sum
- name: Lint
# Only need to lint the code once, so just pick one of the arch to run on.
if: ${{ matrix.arch.arch == 'amd64' }}
uses: golangci/golangci-lint-action@v6
with:
## https://github.com/golangci/golangci-lint-action/issues/369
working-directory: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman
version: v1.54.2
skip-cache: true
skip-save-cache: true
args: -v --timeout 5m

- name: Build Examples
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=${{ matrix.arch.arch }} go build ./...
- name: Build Operator
run: GOARCH=${{ matrix.arch.arch }} make build

- name: Verify Autogenerated Code
# Only need to run verify once, so just pick one of the arch to run on.
if: ${{ matrix.arch.arch == 'amd64' }}
run: make verify

- name: Run Tests
run: make test

- name: Archive Go code coverage results
# Only need to run the test coverage for once, so just pick one of the arch to run on.
if: ${{ matrix.arch.arch == 'amd64' }}
uses: actions/upload-artifact@v4
with:
name: coverage-go
path: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman/bpfman-operator/cover.out
if-no-files-found: error
cd examples
GOARCH=${{ matrix.arch.arch }} make build
build-docs:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -418,9 +380,6 @@ jobs:
- name: Run the bpfman installer
run: sudo ./scripts/setup.sh install

- name: Give certs time to be created
run: sleep 5

- name: Verify the bpfman systemd service is active
run: systemctl is-active bpfman.socket

Expand All @@ -438,109 +397,10 @@ jobs:
- name: Run integration tests
run: cargo xtask integration-test

kubernetes-integration-tests:
needs: [build, build-go, build-docs]
runs-on: ubuntu-latest
env:
BPFMAN_IMG: quay.io/bpfman/bpfman:int-test
BPFMAN_AGENT_IMG: quay.io/bpfman/bpfman-agent:int-test
BPFMAN_OPERATOR_IMG: quay.io/bpfman/bpfman-operator:int-test
XDP_PASS_PRIVATE_IMAGE_CREDS: ${{ secrets.XDP_PASS_PRIVATE_IMAGE_CREDS }}
steps:
- name: Check disk space
run: df -h

- name: Free up space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo rm -rf /usr/local/lib/android
# The following are additional commands that could be run to free up
# more space if necessary:
#
# sudo apt-get update
# sudo eatmydata apt-get purge --auto-remove -y \
# azure-cli aspnetcore-* dotnet-* ghc-* firefox \
# google-chrome-stable \
# llvm-* microsoft-edge-stable mono-* \
# msbuild mysql-server-core-* php-* php7* \
# powershell temurin-* zulu-*
# sudo apt-get autoremove -y
# sudo apt-get autoclean -y
# sudo docker system prune -a -f --volumes

- name: Check disk space again
run: df -h

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -qy \
git \
clang \
llvm \
gcc-multilib \
libbpf-dev
- name: setup golang
uses: actions/setup-go@v5
with:
# prettier-ignore
go-version: '1.22' # yamllint disable-line rule:quoted-strings

- name: cache go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-build-codegen-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-build-codegen-
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

## TODO(astoycos) Currently this is just done to ensure we have coverage
## on all image builds. Ultimately we should be running the integration
## tests with these locally built bytecode images.
- name: build example bytecode images
run: |
go install github.com/cilium/ebpf/cmd/[email protected]
cd examples
make build-all-images
- name: build images
run: cd bpfman-operator && make build-images

- name: run integration tests
run: cd bpfman-operator && make test-integration

- name: Check disk space
run: df -h

## Upload diagnostics if integration test step failed.
- name: upload diagnostics
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: kubernetes-integration-test-diag
path: /tmp/ktf-diag*
if-no-files-found: ignore

coverage:
needs: [build, build-go]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Download golang coverage artifacts
uses: actions/download-artifact@v4
with:
name: coverage-go

- name: Download rust coverage artifacts
uses: actions/download-artifact@v4
with:
Expand All @@ -549,7 +409,7 @@ jobs:
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./cover.out,./lcov.info
files: ./lcov.info
verbose: true

# Creates Release
Expand Down Expand Up @@ -608,7 +468,6 @@ jobs:
build-docs,
coverage,
basic-integration-tests,
kubernetes-integration-tests,
]
runs-on: ubuntu-latest
steps:
Expand Down
55 changes: 0 additions & 55 deletions .github/workflows/image-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,48 +35,6 @@ jobs:
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
# build_language: go - Not building locally, so don't install go tools
repository: bpfman
image: bpfman-agent
dockerfile: ./bpfman-operator/Containerfile.bpfman-agent
context: .
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
# build_language: go - Not building locally, so don't install go tools
repository: bpfman
image: bpfman-operator
dockerfile: ./bpfman-operator/Containerfile.bpfman-operator
context: .
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
# build_language: go - Not building locally, so don't install go tools
repository: bpfman
image: bpfman-operator-bundle
context: ./bpfman-operator
dockerfile: ./bpfman-operator/Containerfile.bundle
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
# build_language: go - Not building locally, so don't install go tools
repository: bpfman-userspace
Expand Down Expand Up @@ -183,11 +141,6 @@ jobs:
- name: Install cosign
uses: sigstore/[email protected]

- name: Generate olm bundle on disk
if: ${{ matrix.image.image == 'bpfman-operator-bundle' }}
run: |
cd bpfman-operator && make bundle
- name: Login to quay.io/bpfman
uses: redhat-actions/podman-login@v1
if: ${{ github.event_name == 'push' && matrix.image.repository == 'bpfman'}}
Expand All @@ -204,14 +157,6 @@ jobs:
username: ${{ secrets.BPFMAN_USERSPACE_USERNAME }}
password: ${{ secrets.BPFMAN_USERSPACE_ROBOT_TOKEN }}

- name: Login to quay.io/bpfman-bytecode
uses: redhat-actions/podman-login@v1
if: ${{ github.event_name == 'push' && matrix.image.repository == 'bpfman-bytecode' }}
with:
registry: ${{ matrix.image.registry }}
username: ${{ secrets.BPFMAN_BYTECODE_USERNAME }}
password: ${{ secrets.BPFMAN_BYTECODE_ROBOT_TOKEN }}

- name: Extract metadata (tags, labels) for image
id: meta
uses: docker/[email protected]
Expand Down
4 changes: 3 additions & 1 deletion Containerfile.bpfman
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ FROM --platform=$BUILDPLATFORM rust:1 as bpfman-build

ARG BUILDPLATFORM

# The following ARGs are set internally by docker or podman on multiarch builds
# The following ARGs are set internally by docker/build-push-action in github actions
ARG TARGETARCH=amd64
ARG TARGETOS=linux
ARG TARGETPLATFORM=linux/amd64

RUN echo "TARGETOS=${TARGETOS} TARGETARCH=${TARGETARCH} BUILDPLATFORM=${BUILDPLATFORM} TARGETPLATFORM=${TARGETPLATFORM}"

RUN apt-get update

WORKDIR /usr/src/bpfman
Expand Down
5 changes: 4 additions & 1 deletion bpfman-operator/Containerfile.bpfman-agent
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ FROM --platform=$BUILDPLATFORM golang:1.22 as bpfman-agent-build

ARG BUILDPLATFORM

# The following ARGs are set internally by docker or podman on multiarch builds
# The following ARGs are set internally by docker/build-push-action in github actions
ARG TARGETOS
ARG TARGETARCH
ARG TARGETPLATFORM

RUN echo "TARGETOS=${TARGETOS} TARGETARCH=${TARGETARCH} BUILDPLATFORM=${BUILDPLATFORM} TARGETPLATFORM=${TARGETPLATFORM}"

WORKDIR /usr/src/bpfman/

Expand Down
5 changes: 4 additions & 1 deletion bpfman-operator/Containerfile.bpfman-operator
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ FROM --platform=$BUILDPLATFORM golang:1.22 as bpfman-operator-build

ARG BUILDPLATFORM

# The following ARGs are set internally by docker or podman on multiarch builds
# The following ARGs are set internally by docker/build-push-action in github actions
ARG TARGETOS
ARG TARGETARCH
ARG TARGETPLATFORM

RUN echo "TARGETOS=${TARGETOS} TARGETARCH=${TARGETARCH} BUILDPLATFORM=${BUILDPLATFORM} TARGETPLATFORM=${TARGETPLATFORM}"

WORKDIR /usr/src/bpfman/

Expand Down
19 changes: 15 additions & 4 deletions bpfman-operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ generate-typed-informers: informer-gen ## Generate typed informers code
--versioned-clientset-package "${PKG}/pkg/client/clientset/versioned" \
--listers-package "${PKG}/pkg/client/listers" \
--output-package "${PKG}/pkg/client/informers" \
${COMMON_FLAGS}

.PHONY: fmt
fmt: ## Run go fmt against code.
Expand Down Expand Up @@ -285,9 +284,21 @@ build: fmt ## Build bpfman-operator and bpfman-agent binaries.
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
.PHONY: build-images
build-images: ## Build bpfman, bpfman-agent, and bpfman-operator images.
docker buildx build -t ${BPFMAN_OPERATOR_IMG} --platform ${PLATFORM} --load -f Containerfile.bpfman-operator ../
docker buildx build -t ${BPFMAN_AGENT_IMG} --platform ${PLATFORM} --load -f Containerfile.bpfman-agent ../
DOCKER_BUILDKIT=1 docker buildx build -t ${BPFMAN_IMG} --platform ${PLATFORM} --load -f ../Containerfile.bpfman.local ../
docker buildx build --load -t ${BPFMAN_OPERATOR_IMG} \
--build-arg TARGETPLATFORM=linux/$(GOARCH) \
--build-arg TARGETARCH=$(GOARCH) \
--build-arg BUILDPLATFORM=linux/amd64 \
-f Containerfile.bpfman-operator ../
docker buildx build --load -t ${BPFMAN_AGENT_IMG} \
--build-arg TARGETPLATFORM=linux/$(GOARCH) \
--build-arg TARGETARCH=$(GOARCH) \
--build-arg BUILDPLATFORM=linux/amd64 \
-f Containerfile.bpfman-agent ../
DOCKER_BUILDKIT=1 docker buildx build --load -t ${BPFMAN_IMG} \
--build-arg TARGETPLATFORM=linux/$(GOARCH) \
--build-arg TARGETARCH=$(GOARCH) \
--build-arg BUILDPLATFORM=linux/amd64 \
-f ../Containerfile.bpfman.local ../

.PHONY: push-images
push-images: ## Push bpfman, bpfman-agent, bpfman-operator images.
Expand Down

0 comments on commit fecff25

Please sign in to comment.