From a6b695189e91423fcd5414495af3b857a92ceb82 Mon Sep 17 00:00:00 2001 From: Rehan Khan Date: Fri, 20 Sep 2024 17:34:54 +0530 Subject: [PATCH 1/3] Added s390x and ppc64le support after rebasing Signed-off-by: Rehan Khan --- backend/Dockerfile | 13 +++++++--- backend/Dockerfile.driver | 8 +++++- backend/Dockerfile.launcher | 7 ++++- backend/Makefile | 15 ++++++----- backend/api/Dockerfile | 26 ++++++++++++++++--- backend/src/cache/deployer/Dockerfile | 10 +++++-- .../cache/deployer/deploy-cache-service.sh | 13 +++++++++- third_party/minio/Dockerfile | 3 ++- 8 files changed, 76 insertions(+), 19 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index fc8d1ca8467..cc56aea320e 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,3 +1,4 @@ + # Copyright 2021-2022 The Kubeflow Authors # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,9 +37,15 @@ RUN python3 -m pip install -r requirements.txt --no-cache-dir # Downloading Argo CLI so that the samples are validated ENV ARGO_VERSION v3.4.17 RUN curl -sLO https://github.com/argoproj/argo-workflows/releases/download/${ARGO_VERSION}/argo-linux-amd64.gz && \ - gunzip argo-linux-amd64.gz && \ - chmod +x argo-linux-amd64 && \ - mv ./argo-linux-amd64 /usr/local/bin/argo +#Support s390x and ppc64le +RUN ARCH=$(uname -m); \ + if [ "$ARCH" = "x86_64" ]; then \ + ARCH="amd64"; \ + fi \ + && curl -sLO https://github.com/argoproj/argo-workflows/releases/download/${ARGO_VERSION}/argo-linux-${ARCH}.gz && \ + gunzip argo-linux-${ARCH}.gz && \ + chmod +x argo-linux-${ARCH} && \ + mv ./argo-linux-${ARCH} /usr/local/bin/argo WORKDIR / COPY ./samples /samples diff --git a/backend/Dockerfile.driver b/backend/Dockerfile.driver index 4f34cb42851..030dac69aad 100644 --- a/backend/Dockerfile.driver +++ b/backend/Dockerfile.driver @@ -1,3 +1,4 @@ + # Copyright 2023 The Kubeflow Authors # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,7 +18,12 @@ FROM golang:1.21.7-alpine3.19 as builder WORKDIR /go/src/github.com/kubeflow/pipelines COPY . . -RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags netgo -ldflags '-extldflags "-static"' -o /bin/driver ./backend/src/v2/cmd/driver/*.go +RUN ARCH=$(uname -m) && \ + if [ "$ARCH" = "x86_64" ]; then \ + ARCH="amd64"; \ + fi && \ + GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=$ARCH go build -tags netgo -ldflags '-extldflags "-static"' -o /bin/driver ./backend/src/v2/cmd/driver/*.go + # Check licenses and comply with license terms. RUN ./hack/install-go-licenses.sh diff --git a/backend/Dockerfile.launcher b/backend/Dockerfile.launcher index 30fc8b05789..ef739250355 100644 --- a/backend/Dockerfile.launcher +++ b/backend/Dockerfile.launcher @@ -1,3 +1,4 @@ + # Copyright 2023 The Kubeflow Authors # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,7 +18,11 @@ FROM golang:1.21.7-alpine3.19 as builder WORKDIR /go/src/github.com/kubeflow/pipelines COPY . . -RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags netgo -ldflags '-extldflags "-static"' -o /bin/launcher-v2 ./backend/src/v2/cmd/launcher-v2/*.go +RUN ARCH=$(uname -m) && \ + if [ "$ARCH" = "x86_64" ]; then \ + ARCH="amd64"; \ + fi && \ + GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=$ARCH go build -tags netgo -ldflags '-extldflags "-static"' -o /bin/launcher-v2 ./backend/src/v2/cmd/launcher-v2/*.go # Check licenses and comply with license terms. RUN ./hack/install-go-licenses.sh diff --git a/backend/Makefile b/backend/Makefile index 583a0d6674e..2d36f4f770a 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -4,6 +4,7 @@ CSV_PATH=backend/third_party_licenses # Container Build Params CONTAINER_ENGINE ?= docker +PLATFORMS ?= linux/amd64,linux/s390x,linux/ppc64le IMG_TAG_APISERVER ?= apiserver IMG_TAG_PERSISTENCEAGENT ?= persistence-agent IMG_TAG_CACHESERVER ?= cache-server @@ -66,25 +67,25 @@ image_all: image_apiserver image_persistence_agent image_cache image_swf image_v .PHONY: image_apiserver image_apiserver: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} build -t ${IMG_TAG_APISERVER} -f backend/Dockerfile . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_APISERVER} -f backend/Dockerfile --push . .PHONY: image_persistence_agent image_persistence_agent: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} build -t ${IMG_TAG_PERSISTENCEAGENT} -f backend/Dockerfile.persistenceagent . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_PERSISTENCEAGENT} -f backend/Dockerfile.persistenceagent --push . .PHONY: image_cache image_cache: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} build -t ${IMG_TAG_CACHESERVER} -f backend/Dockerfile.cacheserver . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_CACHESERVER} -f backend/Dockerfile.cacheserverbuildx build --platform $(PLATFORMS) .PHONY: image_swf image_swf: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} build -t ${IMG_TAG_SCHEDULEDWORKFLOW} -f backend/Dockerfile.scheduledworkflow . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_SCHEDULEDWORKFLOW} -f backend/Dockerfile.scheduledworkflow --push . .PHONY: image_viewer image_viewer: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} build -t ${IMG_TAG_VIEWERCONTROLLER} -f backend/Dockerfile.viewercontroller . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_VIEWERCONTROLLER} -f backend/Dockerfile.viewercontroller --push . .PHONY: image_visualization image_visualization: cd $(MOD_ROOT) && ${CONTAINER_ENGINE} build -t ${IMG_TAG_VISUALIZATION} -f backend/Dockerfile.visualization . .PHONY: image_driver image_driver: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} build -t ${IMG_TAG_DRIVER} -f backend/Dockerfile.driver . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_DRIVER} -f backend/Dockerfile.driver --push . .PHONY: image_launcher image_launcher: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} build -t ${IMG_TAG_LAUNCHER} -f backend/Dockerfile.launcher . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS)-t ${IMG_TAG_LAUNCHER} -f backend/Dockerfile.launcher --push . diff --git a/backend/api/Dockerfile b/backend/api/Dockerfile index 786ad2c0d3b..0b36f0e7bc4 100644 --- a/backend/api/Dockerfile +++ b/backend/api/Dockerfile @@ -1,3 +1,4 @@ + # Copyright 2021 The Kubeflow Authors # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +24,8 @@ ENV GOBIN=/go/bin # Install protoc. RUN apt-get update -y && apt-get install -y jq sed unzip -RUN curl -L -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip +RUN ARCH=$(uname -m); \ + && curl -L -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-${ARCH}.zip RUN unzip -o protoc.zip -d /usr/ bin/protoc RUN unzip -o protoc.zip -d /usr/ 'include/*' RUN rm -f protoc.zip @@ -41,8 +43,26 @@ RUN go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@la RUN go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@latest # Download go-swagger binary. -RUN curl -LO "https://github.com/go-swagger/go-swagger/releases/download/${GO_SWAGGER_VERSION}/swagger_linux_amd64" -RUN chmod +x swagger_linux_amd64 && mv swagger_linux_amd64 /usr/bin/swagger +#building go-swagger binary for s390x and ppc64le since pre built binaries are not available for these platforms +RUN /bin/sh -c ARCH=$(uname -m) && \ + if [ "$ARCH" = "x86_64" ]; then \ + ARCH="amd64" && \ + curl -LO "https://github.com/go-swagger/go-swagger/releases/download/${GO_SWAGGER_VERSION}/swagger_linux_${ARCH}" && \ + chmod +x swagger_linux_${ARCH} && \ + mv swagger_linux_${ARCH} /usr/bin/swagger; \ + else \ + dir=$(mktemp -d) && \ + git clone https://github.com/go-swagger/go-swagger "$dir" && \ + cd "$dir" && \ + git checkout v${GO_SWAGGER_VERSION} && \ + LDFLAGS="-s -w -X github.com/$GITHUB_REPOSITORY/cmd/swagger/commands.Commit=${GITHUB_SHA}"; \ + LDFLAGS="$LDFLAGS -X github.com/$GITHUB_REPOSITORY/cmd/swagger/commands.Version=${GITHUB_REF_NAME-dev}"; \ + out="swagger_linux_$ARCH"; \ + GOOS=linux GOARCH=$ARCH CGO_ENABLED=0 go build -ldflags "$LDFLAGS" -o "./dist/bin/$out" ./cmd/swagger; \ + mv "./dist/bin/$out" /usr/bin/swagger && \ + cd / && \ + rm -rf "$dir"; \ + fi # Need protobuf source code for -I in protoc command. RUN mkdir golang && cd golang && git clone --depth 1 --branch $GOLANG_PROTOBUF_VERSION https://github.com/golang/protobuf.git diff --git a/backend/src/cache/deployer/Dockerfile b/backend/src/cache/deployer/Dockerfile index abae217a73f..6e6103f41c4 100644 --- a/backend/src/cache/deployer/Dockerfile +++ b/backend/src/cache/deployer/Dockerfile @@ -1,11 +1,17 @@ -FROM gcr.io/google.com/cloudsdktool/google-cloud-cli:alpine +FROM alpine RUN apk add --update \ curl \ jq \ openssl -RUN gcloud components install kubectl + RUN ARCH=$(uname -m); \ + if [ "$ARCH" = "x86_64" ]; then \ + ARCH="amd64"; \ + fi \ + && curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/${ARCH}/kubectl \ + && chmod +x ./kubectl \ + && mv ./kubectl /usr/local/bin/kubectl ADD backend/src/cache/deployer/* /kfp/cache/deployer/ RUN chmod -R 777 /kfp/cache/deployer diff --git a/backend/src/cache/deployer/deploy-cache-service.sh b/backend/src/cache/deployer/deploy-cache-service.sh index 9d8ac9b6b01..335477dcb35 100755 --- a/backend/src/cache/deployer/deploy-cache-service.sh +++ b/backend/src/cache/deployer/deploy-cache-service.sh @@ -1,3 +1,4 @@ + #!/bin/bash # # Copyright 2020 The Kubeflow Authors @@ -35,11 +36,21 @@ export PATH="$HOME/bin:$PATH" { server_version_major_minor=$(kubectl version --output json | jq --raw-output '(.serverVersion.major + "." + .serverVersion.minor)' | tr -d '"+') stable_build_version=$(curl -s "https://storage.googleapis.com/kubernetes-release/release/stable-${server_version_major_minor}.txt") - kubectl_url="https://storage.googleapis.com/kubernetes-release/release/${stable_build_version}/bin/linux/amd64/kubectl" + if [ "$ARCH" = "amd64" ]; then + kubectl_url="https://storage.googleapis.com/kubernetes-release/release/${stable_build_version}/bin/linux/amd64/kubectl" + elif [ "$ARCH" = "s390x" ]; then #support for s390x + kubectl_url="https://storage.googleapis.com/kubernetes-release/release/${stable_build_version}/bin/linux/s390x/kubectl" + elif [ "$ARCH" = "ppc64le" ]; then # support for ppc64le + kubectl_url="https://storage.googleapis.com/kubernetes-release/release/${stable_build_version}/bin/linux/ppc64le/kubectl" + else + echo "Unsupported architecture: $ARCH" + exit 1 + fi curl -L -o "$HOME/bin/kubectl" "$kubectl_url" chmod +x "$HOME/bin/kubectl" } || true + # This should fail if there are connectivity problems # Gotcha: Listing all objects requires list permission, # but when listing a single oblect kubectl will fail if it's not found diff --git a/third_party/minio/Dockerfile b/third_party/minio/Dockerfile index 0c5cffcc7f8..23cf6897cba 100644 --- a/third_party/minio/Dockerfile +++ b/third_party/minio/Dockerfile @@ -23,7 +23,8 @@ RUN sh /third_party/download_source.sh Date: Mon, 23 Sep 2024 10:41:21 +0530 Subject: [PATCH 2/3] Fixed argo installation in Dockerfile Signed-off-by: Rehan Khan --- backend/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index cc56aea320e..fa00a150a1e 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -36,7 +36,6 @@ RUN python3 -m pip install -r requirements.txt --no-cache-dir # Downloading Argo CLI so that the samples are validated ENV ARGO_VERSION v3.4.17 -RUN curl -sLO https://github.com/argoproj/argo-workflows/releases/download/${ARGO_VERSION}/argo-linux-amd64.gz && \ #Support s390x and ppc64le RUN ARCH=$(uname -m); \ if [ "$ARCH" = "x86_64" ]; then \ From b573e985bc73ea6e7c4da07cb35393b965240b1c Mon Sep 17 00:00:00 2001 From: Rehan Khan Date: Tue, 24 Sep 2024 11:28:06 +0530 Subject: [PATCH 3/3] Made the requested changes Signed-off-by: Rehan Khan --- backend/Dockerfile.launcher | 1 - backend/Makefile | 16 ++++++++-------- backend/api/Dockerfile | 1 - .../src/cache/deployer/deploy-cache-service.sh | 2 -- third_party/minio/Dockerfile | 1 - 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/backend/Dockerfile.launcher b/backend/Dockerfile.launcher index ef739250355..171c3495450 100644 --- a/backend/Dockerfile.launcher +++ b/backend/Dockerfile.launcher @@ -1,4 +1,3 @@ - # Copyright 2023 The Kubeflow Authors # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/backend/Makefile b/backend/Makefile index 2d36f4f770a..39ad20e7615 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -67,25 +67,25 @@ image_all: image_apiserver image_persistence_agent image_cache image_swf image_v .PHONY: image_apiserver image_apiserver: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_APISERVER} -f backend/Dockerfile --push . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_APISERVER} -f backend/Dockerfile . .PHONY: image_persistence_agent image_persistence_agent: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_PERSISTENCEAGENT} -f backend/Dockerfile.persistenceagent --push . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_PERSISTENCEAGENT} -f backend/Dockerfile.persistenceagent . .PHONY: image_cache image_cache: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_CACHESERVER} -f backend/Dockerfile.cacheserverbuildx build --platform $(PLATFORMS) -.PHONY: image_swf + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_CACHESERVER} -f backend/Dockerfile.cacheserver . +.PHONY: image_swf image_swf: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_SCHEDULEDWORKFLOW} -f backend/Dockerfile.scheduledworkflow --push . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_SCHEDULEDWORKFLOW} -f backend/Dockerfile.scheduledworkflow . .PHONY: image_viewer image_viewer: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_VIEWERCONTROLLER} -f backend/Dockerfile.viewercontroller --push . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_VIEWERCONTROLLER} -f backend/Dockerfile.viewercontroller . .PHONY: image_visualization image_visualization: cd $(MOD_ROOT) && ${CONTAINER_ENGINE} build -t ${IMG_TAG_VISUALIZATION} -f backend/Dockerfile.visualization . .PHONY: image_driver image_driver: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_DRIVER} -f backend/Dockerfile.driver --push . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_DRIVER} -f backend/Dockerfile.driver . .PHONY: image_launcher image_launcher: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS)-t ${IMG_TAG_LAUNCHER} -f backend/Dockerfile.launcher --push . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS)-t ${IMG_TAG_LAUNCHER} -f backend/Dockerfile.launcher . diff --git a/backend/api/Dockerfile b/backend/api/Dockerfile index 0b36f0e7bc4..a9897eba1a3 100644 --- a/backend/api/Dockerfile +++ b/backend/api/Dockerfile @@ -1,4 +1,3 @@ - # Copyright 2021 The Kubeflow Authors # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/backend/src/cache/deployer/deploy-cache-service.sh b/backend/src/cache/deployer/deploy-cache-service.sh index 335477dcb35..f027ea69b86 100755 --- a/backend/src/cache/deployer/deploy-cache-service.sh +++ b/backend/src/cache/deployer/deploy-cache-service.sh @@ -1,4 +1,3 @@ - #!/bin/bash # # Copyright 2020 The Kubeflow Authors @@ -50,7 +49,6 @@ export PATH="$HOME/bin:$PATH" chmod +x "$HOME/bin/kubectl" } || true - # This should fail if there are connectivity problems # Gotcha: Listing all objects requires list permission, # but when listing a single oblect kubectl will fail if it's not found diff --git a/third_party/minio/Dockerfile b/third_party/minio/Dockerfile index 23cf6897cba..be8f9d4dc47 100644 --- a/third_party/minio/Dockerfile +++ b/third_party/minio/Dockerfile @@ -23,7 +23,6 @@ RUN sh /third_party/download_source.sh