Skip to content

Commit

Permalink
OPCT-272: Create Sonobuoy mirror scripts to multi-arch images (#91)
Browse files Browse the repository at this point in the history
Moving the script to mirror sonobuoy image to CLI repo, and adding
support to multi-architectures.

https://issues.redhat.com/browse/OPCT-272

---------

Co-authored-by: Richard Vanderpool <49568690+rvanderp3@users.noreply.github.com>
  • Loading branch information
mtulio and rvanderp3 committed Oct 18, 2023
1 parent 43352dd commit 7e3a2e1
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ build-darwin-arm64: build
linux-amd64-container: build-linux-amd64
podman build -t $(IMG):latest -f hack/Containerfile --build-arg=RELEASE_TAG=$(RELEASE_TAG) .

.PHONY: image-mirror-sonobuoy
image-mirror-sonobuoy:
./hack/image-mirror-sonobuoy/mirror.sh

# Utils dev
.PHONY: update-go
update-go:
Expand Down
44 changes: 44 additions & 0 deletions docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Table of Contents:
- [Development Notes](#dev-notes)
- [Command Line Interface](#dev-cli)
- [Integration with Sonobuoy CLI](#dev-integration-cli)
- [Mirror sonobuoy images](#dev-image-mirror-sonobuoy)
- [Sonobuoy Plugins](#dev-sonobuoy-plugins)
- [Diagrams](#dev-diagrams)
- [CLI Result filters](#dev-diagram-filters)
Expand Down Expand Up @@ -127,6 +128,49 @@ reader, ec, err := config.SonobuoyClient.RetrieveResults(&client.RetrieveConfig{
})
```

#### Sonobuoy image mirroring <a name="dev-image-mirror-sonobuoy"></a>

The Sonobuoy images for Aggregator server and worker are mirrored to quay.io to prevent
issues with docker hub network throttling.

The Sonobuoy image must follow the same of OPCT CLI (sonobuoy library defined in go.mod).

**Running the mirror**

The mirror steps must be executed every time the Sonobuoy package is update on CLI, the following steps describes how to start the mirror process:

- Update the version `SONOBUOY_VERSION` in [`hack/image-mirror-sonobuoy/mirror.sh`][image-mirror-sonobuoy]
- Run mirror script
```bash
make image-mirror-sonobuoy
```
- Check the image in [quay.io/opct/sonobuoy](https://quay.io/repository/opct/sonobuoy?tab=tags)

**Running the mirror targetting custom repository**

```bash
SONOBUOY_VERSION=v0.56.11 MIRROR_REPO=quay.io/mrbraga/sonobuoy make image-mirror-sonobuoy
```

**Adding new Architecture**

If you are looking to test a new platform, you must add it when creating the manifest in [`hack/image-mirror-sonobuoy/mirror.sh`][image-mirror-sonobuoy]:

```bash
BUILD_PLATFORMS+=( ["windows-amd64"]="windows/amd64" )
```

**Testing custom sonobuoy images in unsupported architectures**

```bash
~/opct/bin/opct-devel run -w \
--sonobuoy-image quay.io/mrbraga/sonobuoy:v0.56.12-linux-arm64 \
--plugins-image openshift-tests-provider-cert:v0.5.0-alpha.3
```

[image-mirror-sonobuoy]: https://github.com/redhat-openshift-ecosystem/provider-certification-tool/tree/main/hack/image-mirror-sonobuoy/mirror.sh


## Sonobuoy Plugins <a name="dev-sonobuoy-plugins"></a>

OPCT is extended by Sonobuoy Plugins.
Expand Down
1 change: 1 addition & 0 deletions hack/image-mirror-sonobuoy/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM ${SONOBUOY_REPO}:${SONOBUOY_VERSION}
35 changes: 35 additions & 0 deletions hack/image-mirror-sonobuoy/mirror.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

# Mirror sonobuoy image to OPCT repo.

set -o pipefail
set -o nounset
set -o errexit

export SONOBUOY_VERSION=${SONOBUOY_VERSION:-v0.56.10}
export SONOBUOY_REPO=docker.io/sonobuoy/sonobuoy
export MIRROR_REPO=${MIRROR_REPO:-quay.io/opct/sonobuoy}
export PLATFORM_IMAGES=""

declare -A BUILD_PLATFORMS=()
BUILD_PLATFORMS+=( ["linux-amd64"]="linux/amd64" )
BUILD_PLATFORMS+=( ["linux-arm64"]="linux/arm64" )
BUILD_PLATFORMS+=( ["linux-ppc64le"]="linux/ppc64le" )
BUILD_PLATFORMS+=( ["linux-s390x"]="linux/s390x" )

mkdir -p build/
envsubst < "$(dirname "$0")"/Containerfile > build/sonobuoy.Containerfile

for arch in ${!BUILD_PLATFORMS[*]}
do
img_name="${MIRROR_REPO}:${SONOBUOY_VERSION}-${arch}"
podman build --platform "${BUILD_PLATFORMS[$arch]}" \
-f build/sonobuoy.Containerfile \
-t "${img_name}" . &&\
podman push "${img_name}" &&\
PLATFORM_IMAGES+=" ${img_name}"
done

podman manifest create ${MIRROR_REPO}:${SONOBUOY_VERSION} ${PLATFORM_IMAGES}
podman manifest push ${MIRROR_REPO}:${SONOBUOY_VERSION} docker://${MIRROR_REPO}:${SONOBUOY_VERSION}

0 comments on commit 7e3a2e1

Please sign in to comment.