From 154bce1e8cc74cf8da86788f95a98c6ccc5bcf51 Mon Sep 17 00:00:00 2001 From: Martin Rowe Date: Sat, 9 May 2026 18:29:46 +1000 Subject: [PATCH 1/3] feat: arm64 controller Builds the controller/manager container for both amd64 and arm64, in a single multi-platform image. This allows control plane nodes running arm64/aarch64 CPUs to be able to manage clusters with AMD GPUs. Not changes: - Build host still has to be amd64/x86_64 - GPU node still has to be amd64/x86_64 - e2e still only tests amd64/x86_64 Benefits: - Heterogeneous/multi-arch clusters do not need dedicated amd64/x86_64 control plane nodes just to control AMD GPU scheduling. Resolves #331 --- .gitignore | 3 ++- Dockerfile | 6 ++++-- Dockerfile.build | 10 ++++++++-- Makefile | 9 +++++---- internal/utils_container/Dockerfile | 5 +++-- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 1c27b74c5..f600d32b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ /bin/ -/manager +/manager* *.tgz /*gpu-operator*.tgz /helm-charts-k8s/charts/*.tgz @@ -26,6 +26,7 @@ tests/pytests/* .cline_storage .vscode +.idea branch_policy.yml tools-internal/* docs-internal/* diff --git a/Dockerfile b/Dockerfile index 33fda9144..e270e3c9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,18 +36,20 @@ RUN cd helm-charts-k8s/charts && \ tar -xvzf node-feature-discovery-chart-0.18.3.tgz ARG TARGET +ARG TARGETARCH # Build RUN git config --global --add safe.directory ${PWD} && make ${TARGET} -RUN curl -LO https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl && \ +RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${TARGETARCH}/kubectl" && \ chmod +x ./kubectl FROM ${OPERATOR_CONTROLLER_BASE_IMAGE} ARG TARGET +ARG TARGETARCH -COPY --from=builder /opt/app-root/src/${TARGET} /usr/local/bin/manager +COPY --from=builder /opt/app-root/src/${TARGET}.${TARGETARCH} /usr/local/bin/manager COPY --from=builder /opt/app-root/src/kubectl /usr/local/bin/kubectl COPY --from=builder /opt/app-root/src/LICENSE /licenses/LICENSE COPY --from=builder /opt/app-root/src/helm-charts-k8s/crds/deviceconfig-crd.yaml \ diff --git a/Dockerfile.build b/Dockerfile.build index eb2494afe..721d4f62a 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -24,6 +24,8 @@ RUN apt-get update -y && \ protobuf-compiler \ locales \ ca-certificates \ + qemu-user-static \ + libc6-arm64-cross \ sudo && \ apt-get clean && rm -rf /var/lib/apt/lists/* @@ -71,12 +73,16 @@ RUN curl -o /usr/local/bin/kubectl -LO 'https://dl.k8s.io/release/v1.36.2/bin/li ARG INSECURE_REGISTRY RUN echo "INSECURE_REGISTRY is: $INSECURE_REGISTRY" && \ - if [ -n "$INSECURE_REGISTRY" ]; then \ mkdir -p /etc/docker && \ + if [ -n "$INSECURE_REGISTRY" ]; then \ echo "{ \ - \"insecure-registries\": [\"$INSECURE_REGISTRY\"] \ + \"insecure-registries\": [\"$INSECURE_REGISTRY\"], \ + \"features\": {\"containerd-snapshotter\": true} \ }" > /etc/docker/daemon.json; \ else \ + echo "{ \ + \"features\": {\"containerd-snapshotter\": true} \ + }" > /etc/docker/daemon.json; \ echo "INSECURE_REGISTRY is not set"; \ fi diff --git a/Makefile b/Makefile index 877ecb7c0..ccc180be2 100644 --- a/Makefile +++ b/Makefile @@ -354,11 +354,12 @@ docs-lint: ## Run docs Markdown lint + spelling (full ROCm-style docs lint). ##@ Build manager: $(shell find -name "*.go") go.mod go.sum ## Build manager binary. - go build -ldflags="-X main.Version=$(PROJECT_VERSION) -X main.GitCommit=$(GIT_COMMIT) -X main.BuildTag=$(HOURLY_TAG_LABEL)" -o $@ ./cmd + GOOS=linux GOARCH=amd64 go build -ldflags="-X main.Version=$(PROJECT_VERSION) -X main.GitCommit=$(GIT_COMMIT) -X main.BuildTag=$(HOURLY_TAG_LABEL)" -o $@.amd64 ./cmd + GOOS=linux GOARCH=arm64 go build -ldflags="-X main.Version=$(PROJECT_VERSION) -X main.GitCommit=$(GIT_COMMIT) -X main.BuildTag=$(HOURLY_TAG_LABEL)" -o $@.arm64 ./cmd .PHONY: docker-build docker-build: ## Build docker image with the manager. - DOCKER_BUILDKIT=1 $(CONTAINER_ENGINE) build -t $(IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) --build-arg TARGET=manager --build-arg GOLANG_BASE_IMG=$(GOLANG_BASE_IMG) --build-arg OPERATOR_CONTROLLER_BASE_IMAGE=$(OPERATOR_CONTROLLER_BASE_IMAGE) . + DOCKER_BUILDKIT=1 $(CONTAINER_ENGINE) build --platform linux/amd64,linux/arm64 -t $(IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) --build-arg TARGET=manager --build-arg GOLANG_BASE_IMG=$(GOLANG_BASE_IMG) --build-arg OPERATOR_CONTROLLER_BASE_IMAGE=$(OPERATOR_CONTROLLER_BASE_IMAGE) . .PHONY: docker-push docker-push: ## Push docker image with the manager. @@ -370,7 +371,7 @@ docker-save: ## Save the container image with the manager. .PHONY: docker-build-utils docker-build-utils: ## Build docker image for utils container. - DOCKER_BUILDKIT=1 $(CONTAINER_ENGINE) build -t $(UTILS_IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) -f internal/utils_container/Dockerfile . + DOCKER_BUILDKIT=1 $(CONTAINER_ENGINE) build --platform linux/amd64,linux/arm64 -t $(UTILS_IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) -f internal/utils_container/Dockerfile . .PHONY: docker-push-utils docker-push-utils: ## Push docker image for utils container. @@ -452,7 +453,7 @@ bundle-build: operator-sdk manifests kustomize ## OpenShift Build OLM bundle. KUBECTL_CMD=${KUBECTL_CMD} ./hack/generate-bundle cp $(shell pwd)/hack/openshift-patch/olm-bundle-patch/*.yaml $(shell pwd)/bundle/manifests/ ${OPERATOR_SDK} bundle validate ./bundle - $(CONTAINER_ENGINE) build --label HOURLY_TAG=$(HOURLY_TAG_LABEL) -f bundle.Dockerfile -t $(BUNDLE_IMG) . + DOCKER_BUILDKIT=1 $(CONTAINER_ENGINE) build --platform linux/amd64,linux/arm64 --label HOURLY_TAG=$(HOURLY_TAG_LABEL) -f bundle.Dockerfile -t $(BUNDLE_IMG) . .PHONY: dep-docs dep-docs: diff --git a/internal/utils_container/Dockerfile b/internal/utils_container/Dockerfile index 77913f234..e0a89c085 100644 --- a/internal/utils_container/Dockerfile +++ b/internal/utils_container/Dockerfile @@ -1,4 +1,5 @@ FROM registry.access.redhat.com/ubi9/ubi-minimal:9.8 +ARG TARGETARCH LABEL name="amd-gpu-operator-utils" LABEL maintainer="sriram.ravishankar@amd.com,yan.sun3@amd.com" @@ -17,8 +18,8 @@ ADD LICENSE /licenses/LICENSE # Install kubectl and oc RUN mkdir -p /oc && cd /oc && \ - curl -SsLO 'https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux-amd64-rhel9.tar.gz' && \ - tar -xzf openshift-client-linux-amd64-rhel9.tar.gz -C /oc && \ + curl -SsLO "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux-${TARGETARCH}-rhel9.tar.gz" && \ + tar -xzf "openshift-client-linux-${TARGETARCH}-rhel9.tar.gz" -C /oc && \ cp ./kubectl /usr/local/bin && chmod +x /usr/local/bin/kubectl && \ cp ./oc /usr/local/bin && chmod +x /usr/local/bin/oc && \ rm -rf /oc From 0a4f84b0c402b804a4aca925816f0c2e94d9885b Mon Sep 17 00:00:00 2001 From: Amulyam24 Date: Wed, 3 Jun 2026 11:38:19 +0530 Subject: [PATCH 2/3] Build AMD GPU operator images for ppc64le Signed-off-by: Amulyam24 --- Dockerfile | 7 ++++--- Makefile | 19 +++++++++++++++---- internal/utils_container/Dockerfile | 5 +++-- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index e270e3c9d..72662131b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ ARG GOLANG_BASE_IMG=golang:1.26.5 ARG OPERATOR_CONTROLLER_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi-minimal:9.8 # Build the manager binary -FROM ${GOLANG_BASE_IMG} AS builder +FROM --platform=$BUILDPLATFORM ${GOLANG_BASE_IMG} AS builder USER root @@ -37,11 +37,12 @@ RUN cd helm-charts-k8s/charts && \ ARG TARGET ARG TARGETARCH +ARG TARGETOS # Build -RUN git config --global --add safe.directory ${PWD} && make ${TARGET} +RUN git config --global --add safe.directory ${PWD} && GOOS=${TARGETOS} GOARCH=${TARGETARCH} make ${TARGET} -RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${TARGETARCH}/kubectl" && \ +RUN curl -LO https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${TARGETARCH}/kubectl && \ chmod +x ./kubectl FROM ${OPERATOR_CONTROLLER_BASE_IMAGE} diff --git a/Makefile b/Makefile index ccc180be2..ce5384bc3 100644 --- a/Makefile +++ b/Makefile @@ -357,9 +357,16 @@ manager: $(shell find -name "*.go") go.mod go.sum ## Build manager binary. GOOS=linux GOARCH=amd64 go build -ldflags="-X main.Version=$(PROJECT_VERSION) -X main.GitCommit=$(GIT_COMMIT) -X main.BuildTag=$(HOURLY_TAG_LABEL)" -o $@.amd64 ./cmd GOOS=linux GOARCH=arm64 go build -ldflags="-X main.Version=$(PROJECT_VERSION) -X main.GitCommit=$(GIT_COMMIT) -X main.BuildTag=$(HOURLY_TAG_LABEL)" -o $@.arm64 ./cmd +# Platforms for multi-arch builds +PLATFORMS ?= linux/amd64,linux/ppc64le + .PHONY: docker-build -docker-build: ## Build docker image with the manager. - DOCKER_BUILDKIT=1 $(CONTAINER_ENGINE) build --platform linux/amd64,linux/arm64 -t $(IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) --build-arg TARGET=manager --build-arg GOLANG_BASE_IMG=$(GOLANG_BASE_IMG) --build-arg OPERATOR_CONTROLLER_BASE_IMAGE=$(OPERATOR_CONTROLLER_BASE_IMAGE) . +docker-build: ## Build and push multi-arch docker image with the manager. + docker buildx build --platform $(PLATFORMS) -t $(IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) --build-arg TARGET=manager --build-arg GOLANG_BASE_IMG=$(GOLANG_BASE_IMG) --build-arg OPERATOR_CONTROLLER_BASE_IMAGE=$(OPERATOR_CONTROLLER_BASE_IMAGE) --push . + +.PHONY: docker-build-local +docker-build-local: ## Build docker image locally for current architecture only (no push). + DOCKER_BUILDKIT=1 docker build -t $(IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) --build-arg TARGET=manager --build-arg GOLANG_BASE_IMG=$(GOLANG_BASE_IMG) --build-arg OPERATOR_CONTROLLER_BASE_IMAGE=$(OPERATOR_CONTROLLER_BASE_IMAGE) . .PHONY: docker-push docker-push: ## Push docker image with the manager. @@ -370,8 +377,12 @@ docker-save: ## Save the container image with the manager. $(CONTAINER_ENGINE) save $(IMG) | gzip > $(IMAGE_NAME).tar.gz .PHONY: docker-build-utils -docker-build-utils: ## Build docker image for utils container. - DOCKER_BUILDKIT=1 $(CONTAINER_ENGINE) build --platform linux/amd64,linux/arm64 -t $(UTILS_IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) -f internal/utils_container/Dockerfile . +docker-build-utils: ## Build and push multi-arch docker image for utils container. + docker buildx build --platform $(PLATFORMS) -t $(UTILS_IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) -f internal/utils_container/Dockerfile --push . + +.PHONY: docker-build-utils-local +docker-build-utils-local: ## Build utils docker image locally for current architecture only (no push). + DOCKER_BUILDKIT=1 docker build -t $(UTILS_IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) -f internal/utils_container/Dockerfile . .PHONY: docker-push-utils docker-push-utils: ## Push docker image for utils container. diff --git a/internal/utils_container/Dockerfile b/internal/utils_container/Dockerfile index e0a89c085..fd680323d 100644 --- a/internal/utils_container/Dockerfile +++ b/internal/utils_container/Dockerfile @@ -16,10 +16,11 @@ RUN microdnf install -y util-linux pciutils kmod tar jq systemd && \ ADD LICENSE /licenses/LICENSE -# Install kubectl and oc +# Install kubectl and oc with architecture detection +ARG TARGETARCH RUN mkdir -p /oc && cd /oc && \ curl -SsLO "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux-${TARGETARCH}-rhel9.tar.gz" && \ - tar -xzf "openshift-client-linux-${TARGETARCH}-rhel9.tar.gz" -C /oc && \ + tar -xzf openshift-client-linux-${TARGETARCH}-rhel9.tar.gz -C /oc && \ cp ./kubectl /usr/local/bin && chmod +x /usr/local/bin/kubectl && \ cp ./oc /usr/local/bin && chmod +x /usr/local/bin/oc && \ rm -rf /oc From d6bd90015a19320087b1bdede32eb2d614e40b44 Mon Sep 17 00:00:00 2001 From: yansun1996 Date: Tue, 4 Aug 2026 22:09:07 +0000 Subject: [PATCH 3/3] build: make controller manager and utils images buildx PLATFORM-configurable Unify the arm64 (#549) and ppc64le (#565) multi-arch work into a single configurable build for both the controller manager and utils container images. docker-build and docker-build-utils run `$(CONTAINER_ENGINE) buildx build --platform "$(PLATFORM)"`, defaulting to PLATFORM=linux/amd64. A single-platform build auto-loads into the local image store. Set PLATFORM to a single platform (linux/arm64) or a comma-separated list; a multi-platform list must be pushed via a direct `buildx --push`. Works with docker buildx and podman 4.0+. buildx auto-populates TARGETOS/TARGETARCH per platform, driving the Go cross-compile, the kubectl download, and the utils container's oc/kubectl client download. Dockerfile.build gains qemu-user-static + libc6-arm64-cross for cross-arch runtime stages. bundle build is left as upstream (amd64). Adds a developer-guide section. Co-Authored-By: Claude --- .wordlist.txt | 1 + Dockerfile | 3 ++- Makefile | 27 +++++++++----------------- docs/contributing/developer-guide.md | 29 ++++++++++++++++++++++++++++ internal/utils_container/Dockerfile | 6 +++--- 5 files changed, 44 insertions(+), 22 deletions(-) diff --git a/.wordlist.txt b/.wordlist.txt index 6d634eb09..f4cbdd1c8 100644 --- a/.wordlist.txt +++ b/.wordlist.txt @@ -163,6 +163,7 @@ PreStateDB prometheus Promethues quay +QEMU QPX RAS RBAC diff --git a/Dockerfile b/Dockerfile index 72662131b..0be902b9a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,6 +36,7 @@ RUN cd helm-charts-k8s/charts && \ tar -xvzf node-feature-discovery-chart-0.18.3.tgz ARG TARGET +# No defaults: buildx sets these per --platform; a default would pin the arch. ARG TARGETARCH ARG TARGETOS @@ -50,7 +51,7 @@ FROM ${OPERATOR_CONTROLLER_BASE_IMAGE} ARG TARGET ARG TARGETARCH -COPY --from=builder /opt/app-root/src/${TARGET}.${TARGETARCH} /usr/local/bin/manager +COPY --from=builder /opt/app-root/src/${TARGET} /usr/local/bin/manager COPY --from=builder /opt/app-root/src/kubectl /usr/local/bin/kubectl COPY --from=builder /opt/app-root/src/LICENSE /licenses/LICENSE COPY --from=builder /opt/app-root/src/helm-charts-k8s/crds/deviceconfig-crd.yaml \ diff --git a/Makefile b/Makefile index ce5384bc3..f20451d5d 100644 --- a/Makefile +++ b/Makefile @@ -353,20 +353,15 @@ docs-lint: ## Run docs Markdown lint + spelling (full ROCm-style docs lint). ##@ Build -manager: $(shell find -name "*.go") go.mod go.sum ## Build manager binary. - GOOS=linux GOARCH=amd64 go build -ldflags="-X main.Version=$(PROJECT_VERSION) -X main.GitCommit=$(GIT_COMMIT) -X main.BuildTag=$(HOURLY_TAG_LABEL)" -o $@.amd64 ./cmd - GOOS=linux GOARCH=arm64 go build -ldflags="-X main.Version=$(PROJECT_VERSION) -X main.GitCommit=$(GIT_COMMIT) -X main.BuildTag=$(HOURLY_TAG_LABEL)" -o $@.arm64 ./cmd +manager: $(shell find -name "*.go") go.mod go.sum ## Build manager binary (honors GOOS/GOARCH from the environment). + go build -ldflags="-X main.Version=$(PROJECT_VERSION) -X main.GitCommit=$(GIT_COMMIT) -X main.BuildTag=$(HOURLY_TAG_LABEL)" -o $@ ./cmd -# Platforms for multi-arch builds -PLATFORMS ?= linux/amd64,linux/ppc64le +# Build platform, default amd64. Set to a list (linux/amd64,linux/arm64) for multi-arch. +PLATFORM ?= linux/amd64 .PHONY: docker-build -docker-build: ## Build and push multi-arch docker image with the manager. - docker buildx build --platform $(PLATFORMS) -t $(IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) --build-arg TARGET=manager --build-arg GOLANG_BASE_IMG=$(GOLANG_BASE_IMG) --build-arg OPERATOR_CONTROLLER_BASE_IMAGE=$(OPERATOR_CONTROLLER_BASE_IMAGE) --push . - -.PHONY: docker-build-local -docker-build-local: ## Build docker image locally for current architecture only (no push). - DOCKER_BUILDKIT=1 docker build -t $(IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) --build-arg TARGET=manager --build-arg GOLANG_BASE_IMG=$(GOLANG_BASE_IMG) --build-arg OPERATOR_CONTROLLER_BASE_IMAGE=$(OPERATOR_CONTROLLER_BASE_IMAGE) . +docker-build: ## Build docker image with the manager (PLATFORM, default linux/amd64). + DOCKER_BUILDKIT=1 $(CONTAINER_ENGINE) buildx build --platform "$(PLATFORM)" -t $(IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) --build-arg TARGET=manager --build-arg GOLANG_BASE_IMG=$(GOLANG_BASE_IMG) --build-arg OPERATOR_CONTROLLER_BASE_IMAGE=$(OPERATOR_CONTROLLER_BASE_IMAGE) . .PHONY: docker-push docker-push: ## Push docker image with the manager. @@ -377,12 +372,8 @@ docker-save: ## Save the container image with the manager. $(CONTAINER_ENGINE) save $(IMG) | gzip > $(IMAGE_NAME).tar.gz .PHONY: docker-build-utils -docker-build-utils: ## Build and push multi-arch docker image for utils container. - docker buildx build --platform $(PLATFORMS) -t $(UTILS_IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) -f internal/utils_container/Dockerfile --push . - -.PHONY: docker-build-utils-local -docker-build-utils-local: ## Build utils docker image locally for current architecture only (no push). - DOCKER_BUILDKIT=1 docker build -t $(UTILS_IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) -f internal/utils_container/Dockerfile . +docker-build-utils: ## Build docker image for utils container (PLATFORM, default linux/amd64). + DOCKER_BUILDKIT=1 $(CONTAINER_ENGINE) buildx build --platform "$(PLATFORM)" -t $(UTILS_IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) -f internal/utils_container/Dockerfile . .PHONY: docker-push-utils docker-push-utils: ## Push docker image for utils container. @@ -464,7 +455,7 @@ bundle-build: operator-sdk manifests kustomize ## OpenShift Build OLM bundle. KUBECTL_CMD=${KUBECTL_CMD} ./hack/generate-bundle cp $(shell pwd)/hack/openshift-patch/olm-bundle-patch/*.yaml $(shell pwd)/bundle/manifests/ ${OPERATOR_SDK} bundle validate ./bundle - DOCKER_BUILDKIT=1 $(CONTAINER_ENGINE) build --platform linux/amd64,linux/arm64 --label HOURLY_TAG=$(HOURLY_TAG_LABEL) -f bundle.Dockerfile -t $(BUNDLE_IMG) . + $(CONTAINER_ENGINE) build --label HOURLY_TAG=$(HOURLY_TAG_LABEL) -f bundle.Dockerfile -t $(BUNDLE_IMG) . .PHONY: dep-docs dep-docs: diff --git a/docs/contributing/developer-guide.md b/docs/contributing/developer-guide.md index cb51e709f..2b37d8d22 100644 --- a/docs/contributing/developer-guide.md +++ b/docs/contributing/developer-guide.md @@ -67,6 +67,35 @@ make docker-push > Note: If you're using a remote registry that requires authentication, ensure you've logged in using `docker login` before pushing. +### Building the controller manager image for a specific architecture + +`make docker-build` runs `$(CONTAINER_ENGINE) buildx build` and is architecture-configurable through the `PLATFORM` variable, which defaults to `linux/amd64`. Set it to a single platform, or a comma-separated list for a multi-arch build. This works with `docker buildx` and with `podman` 4.0+ (which aliases `podman buildx build` to `podman build`). + +```bash +# Default: builds a linux/amd64 image and loads it into the local image store +make docker-build + +# Build a single arm64 image +make docker-build PLATFORM=linux/arm64 +``` + +`buildx` populates the `TARGETOS`/`TARGETARCH` build arguments per platform, which drive both the Go cross-compilation (`GOOS`/`GOARCH`) and the architecture-specific `kubectl` download. With no override, `make docker-build` produces a `linux/amd64` image, unchanged from the previous default. + +A single-platform build is loaded into the local image store automatically. A **multi-platform** `PLATFORM` (e.g. `linux/amd64,linux/arm64`) cannot be loaded locally — buildx must push the resulting manifest list straight to a registry, which the `docker-build` target does not do. For that case, run buildx directly with `--push`. + +The utils container image build follows the same convention through the same `PLATFORM` variable: + +```bash +make docker-build-utils # linux/amd64 +make docker-build-utils PLATFORM=linux/arm64 +``` + +> Note: When building for an architecture different from your host, register QEMU emulation once per host so the runtime stage can execute: +> +> ```bash +> docker run --privileged --rm tonistiigi/binfmt --install arm64,ppc64le +> ``` + - Generate Helm charts: - For vanilla Kubernetes: `make helm` - For OpenShift: `OPENSHIFT=1 make helm` diff --git a/internal/utils_container/Dockerfile b/internal/utils_container/Dockerfile index fd680323d..064d192eb 100644 --- a/internal/utils_container/Dockerfile +++ b/internal/utils_container/Dockerfile @@ -1,5 +1,4 @@ FROM registry.access.redhat.com/ubi9/ubi-minimal:9.8 -ARG TARGETARCH LABEL name="amd-gpu-operator-utils" LABEL maintainer="sriram.ravishankar@amd.com,yan.sun3@amd.com" @@ -16,11 +15,12 @@ RUN microdnf install -y util-linux pciutils kmod tar jq systemd && \ ADD LICENSE /licenses/LICENSE -# Install kubectl and oc with architecture detection +# Install kubectl and oc +# No default: buildx sets TARGETARCH per --platform. ARG TARGETARCH RUN mkdir -p /oc && cd /oc && \ curl -SsLO "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux-${TARGETARCH}-rhel9.tar.gz" && \ - tar -xzf openshift-client-linux-${TARGETARCH}-rhel9.tar.gz -C /oc && \ + tar -xzf "openshift-client-linux-${TARGETARCH}-rhel9.tar.gz" -C /oc && \ cp ./kubectl /usr/local/bin && chmod +x /usr/local/bin/kubectl && \ cp ./oc /usr/local/bin && chmod +x /usr/local/bin/oc && \ rm -rf /oc