-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable multi-platform support for bridge marker image builds #77
Enable multi-platform support for bridge marker image builds #77
Conversation
Hi @ashokpariya0. Thanks for your PR. I'm waiting for a kubevirt member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks looks great
Makefile
Outdated
@@ -1,6 +1,16 @@ | |||
REGISTRY ?= quay.io/kubevirt | |||
IMAGE_TAG ?= latest | |||
IMAGE_GIT_TAG ?= $(shell git describe --abbrev=8 --tags) | |||
PLATFORMS ?= linux/amd64,linux/s390x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets see please we are good to with having s390x by default, or better do the auto detection trick as done on cnao please
it is important to have fast deployment generally speaking imho
Makefile
Outdated
MARKER_IMAGE_TAGGED_1 := ${REGISTRY}/bridge-marker:${IMAGE_TAG} | ||
MARKER_IMAGE_TAGGED_2 := ${REGISTRY}/bridge-marker:${IMAGE_GIT_TAG} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please renamed to MARKER_IMAGE_TAGGED
and MARKER_IMAGE_GIT_TAGGED
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Makefile
Outdated
build-multiarch-marker-podman: | ||
ARCH=$(ARCH) PLATFORMS=$(PLATFORMS) MARKER_IMAGE_TAGGED_1=$(MARKER_IMAGE_TAGGED_1) MARKER_IMAGE_TAGGED_2=$(MARKER_IMAGE_TAGGED_2) ./hack/build-marker-podman.sh | ||
|
||
.PHONY: build build-multiarch-marker-docker build-multiarch-marker-podman format docker-build docker-push manifests cluster-up cluster-down cluster-sync vendor marker tools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use one per line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
build/Dockerfile
Outdated
RUN dnf install -y tar gzip jq && dnf clean all | ||
RUN ARCH=$(uname -m | sed 's/x86_64/amd64/') && \ | ||
GO_VERSION=$(curl -L -s "https://go.dev/dl/?mode=json" | jq -r '.[0].version') && \ | ||
curl -L "https://go.dev/dl/${GO_VERSION}.linux-${ARCH}.tar.gz" -o go.tar.gz && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets take go version from go.mod please, as done on other network repos
easier to maintain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in latest commit.
build/Dockerfile
Outdated
rm go.tar.gz | ||
ENV PATH=$PATH:/usr/local/go/bin | ||
WORKDIR /go/src/bridge-marker | ||
COPY . . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see k8snetworkplumbingwg/ovs-cni#336
nice to copy the go.mod / go.sum, and then have a layer of go mod download
and just at the end the copy . .
in order to have docker layers that enable caching better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
hack/build-marker-docker.sh
Outdated
|
||
IFS=',' read -r -a PLATFORM_LIST <<< "$PLATFORMS" | ||
|
||
BUILD_ARGS="--no-cache --build-arg BUILD_ARCH=$ARCH -f build/Dockerfile -t $MARKER_IMAGE_TAGGED_1 -t $MARKER_IMAGE_TAGGED_2 . --push" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why --no-cache
?
we do need it at least locally usually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in latest commit.
hack/build-marker-podman.sh
Outdated
|
||
IFS=',' read -r -a PLATFORM_LIST <<< "$PLATFORMS" | ||
|
||
# Remove any existing manifests and images |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please drop comments all over, unless non trivial
hack/build-marker-podman.sh
Outdated
|
||
for platform in "${PLATFORM_LIST[@]}"; do | ||
podman build \ | ||
--no-cache \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why no cache ?
speed is important please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
hack/init-buildx.sh
Outdated
if ! docker buildx > /dev/null 2>&1; then | ||
mkdir -p ~/.docker/cli-plugins | ||
BUILDX_VERSION=$(curl -s https://api.github.com/repos/docker/buildx/releases/latest | jq -r .tag_name) | ||
curl -L https://github.com/docker/buildx/releases/download/"${BUILDX_VERSION}"/buildx-"${BUILDX_VERSION}".linux-amd64 --output ~/.docker/cli-plugins/docker-buildx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linux-amd64
hardcoded, is it fine? or we want multi support
what if compiled directly on non amd64, (not cross) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
hack/install-go.sh
Outdated
@@ -2,7 +2,8 @@ | |||
|
|||
destination=$1 | |||
version=$(grep "^go " go.mod |awk '{print $2}') | |||
tarball=go$version.linux-amd64.tar.gz | |||
arch=$(uname -m | sed 's/x86_64/amd64/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets add auto detection please ?
like kubevirt/cluster-network-addons-operator#1928
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added auto detection as default mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be ? (unless for go binary the naming are different)
uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes added for arm64.
b59b33f
to
d1c0939
Compare
@oshoval All review comments have been addressed, Please take look. |
These changes enable building and pushing bridge marker container images for multiple platforms (amd64, s390x, arm64) from a single Dockerfile. Enhanced multi-platform support in the build process by adding a PLATFORMS argument in the Makefile for amd64, s390x, and arm64 architectures. Multi-platform build support is provided for both Docker and Podman container runtimes. Signed-off-by: Ashok Pariya <[email protected]>
d1c0939
to
022e5e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you
@@ -2,7 +2,8 @@ | |||
|
|||
destination=$1 | |||
version=$(grep "^go " go.mod |awk '{print $2}') | |||
tarball=go$version.linux-amd64.tar.gz | |||
arch=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kubevirt/kubesecondarydns@d03ce8e
here the logic is bit different (for s390x), are both fine ? or one should be fixed
thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both are same for s390x case.
Both approaches are fine. However, one thing to note is that linux/ppc64le
will fail with [this commit](kubevirt/kubesecondarydns@d03ce8e), as it explicitly supports only amd64
, arm64
, and s390x
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you
i think we dont support ppc64le atm, please raise it there as well if you want (for visibility)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you i think we dont support ppc64le atm, please raise it there as well if you want (for visibility)
okay, I can see for ipam controller (https://github.com/kubevirt/ipam-extensions/blob/925bee6139751fcb241a435bae8b79ce1dfce595/Makefile#L121C50-L121C63)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes but i dont think we need to support ppc64le generally speaking on other sig network repos
@phoracek please keep me honest here, i think we discussed it once
EDIT - anyhow, imho, even if we need it, it should be on a follow-up all over,
not to be mixed with the current effort which lays the foundations and support for new archs already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oshoval Just to inform you, I noticed that linux/ppc64le
is supported for components like the bridge-operator, OVS, Multus CNI, etc.
ENV PATH=$PATH:/usr/local/go/bin | ||
RUN go mod download | ||
COPY . . | ||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o build/_output/bin/marker github.com/kubevirt/bridge-marker/cmd/marker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imho it is better to be explicit with what we build please
./cmd/marker
EDIT - as we spoke, since it was like that, lets keep it
Thanks @phoracek |
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: phoracek The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Thanks |
Yes we need that info as we have to do export PLATFORMS=all before we build and push images: |
Hi @phoracek |
Please see here the post submit Thanks Petr Once you add the "all", we need to tag and then it will release with tag |
Great! Can I create a PR to add export PLATFORMS=all in the above YAML file under the project-infra repository? |
sure thanks |
PR link: kubevirt/project-infra#3819 |
These changes enable building and pushing bridge marker container images for multiple platforms (amd64, s390x, arm64) from a single Dockerfile. Enhanced multi-platform support in the build process by adding a PLATFORMS argument in the Makefile for amd64, s390x, and arm64 architectures. Multi-platform build support is provided for both Docker and Podman container runtimes.
What this PR does / why we need it:
The upstream
bridge-marker
image ([link](https://quay.io/repository/kubevirt/bridge-marker?tab=tags&tag=latest)) currently supports only the amd64 architecture. The proposed changes in this PR enable multi-platform support for thebridge-marker
image, broadening its compatibility to include additional architectures.Special notes for your reviewer:
Multiplatform build instruction: https://gist.github.com/ashokpariya0/30d5efc0e9525c266ef9e65fe4291860
Multi-platform build support is enabled for both Docker and Podman container runtimes, and the necessary changes have been made accordingly.
The
PLATFORMS
variable defines the target platforms for building the manager image, allowing support for multiple architectures.To use this feature, you need to:
For Docker:
docker buildx
. More information: [Docker Buildx Documentation](https://docs.docker.com/build/building/multi-platform/)For Podman:
Release note: