From 4d7f6eadf1011c60b63bc8e51e7e81051353d8c4 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Wed, 26 Feb 2025 10:34:07 -0800 Subject: [PATCH 1/4] kms-e2e: use setup_env / respect GOTOOLCHAIN --- .../kms/internal/plugins/_mock/Dockerfile | 1 + .../testing-manifests/auth/encrypt/run-e2e.sh | 23 +++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile b/staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile index da79d81fdde..d14ab79cc90 100644 --- a/staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile +++ b/staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile @@ -23,6 +23,7 @@ WORKDIR /workspace/kms/internal/plugins/_mock ARG TARGETARCH ARG TARGETPLATFORM +ARG GOTOOLCHAIN RUN CGO_ENABLED=1 GOOS=linux GOARCH=${TARGETARCH} GO111MODULE=on go build -a -o mock-kms-plugin plugin.go FROM alpine:latest diff --git a/test/e2e/testing-manifests/auth/encrypt/run-e2e.sh b/test/e2e/testing-manifests/auth/encrypt/run-e2e.sh index c1659404118..7b605adfa57 100755 --- a/test/e2e/testing-manifests/auth/encrypt/run-e2e.sh +++ b/test/e2e/testing-manifests/auth/encrypt/run-e2e.sh @@ -25,6 +25,9 @@ set -o errexit set -o nounset set -o pipefail +KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/../../../../.. && pwd -P)" +source "${KUBE_ROOT}/hack/lib/init.sh" + readonly cluster_name="kms" readonly registry_name="kind-registry" readonly kind_network="kind" @@ -35,6 +38,7 @@ build_and_push_mock_plugin() { --no-cache \ --platform linux/amd64 \ --output=type=docker \ + --build-arg=GOTOOLCHAIN="${GOTOOLCHAIN}" \ -t localhost:5000/mock-kms-provider:e2e \ -f staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile staging/src/k8s.io/ \ --progress=plain; @@ -136,18 +140,23 @@ main(){ export ARTIFACTS="${ARTIFACTS:-${PWD}/_artifacts}" mkdir -p "${ARTIFACTS}" - export GO111MODULE=on; - go install sigs.k8s.io/kind@latest; - go install sigs.k8s.io/kubetest2@latest; - go install sigs.k8s.io/kubetest2/kubetest2-kind@latest; - go install sigs.k8s.io/kubetest2/kubetest2-tester-ginkgo@latest; + kube::golang::setup_env + ( + # just while installing external tools + export GO111MODULE=on GOTOOLCHAIN=auto + # TODO: consider using specific versions to avoid surprise breaking changes + go install sigs.k8s.io/kind@latest + go install sigs.k8s.io/kubetest2@latest + go install sigs.k8s.io/kubetest2/kubetest2-kind@latest + go install sigs.k8s.io/kubetest2/kubetest2-tester-ginkgo@latest + ) # The build e2e.test, ginkgo and kubectl binaries + copy to dockerized dir is # because of https://github.com/kubernetes-sigs/kubetest2/issues/184 - make all WHAT="test/e2e/e2e.test vendor/github.com/onsi/ginkgo/v2/ginkgo cmd/kubectl"; + make all WHAT="test/e2e/e2e.test vendor/github.com/onsi/ginkgo/v2/ginkgo cmd/kubectl" mkdir -p _output/dockerized/bin/linux/amd64; for binary in kubectl e2e.test ginkgo; do - cp -f _output/local/go/bin/${binary} _output/dockerized/bin/linux/amd64/${binary}; + cp -f _output/local/go/bin/${binary} _output/dockerized/bin/linux/amd64/${binary} done; create_registry From a3009258dace3414f68b63ba63c8a24e4089d5c0 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Wed, 26 Feb 2025 11:33:29 -0800 Subject: [PATCH 2/4] fix dockerfile warning --- staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile b/staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile index d14ab79cc90..179ef178c91 100644 --- a/staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile +++ b/staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.24.0-bullseye as builder +FROM golang:1.24.0-bullseye AS builder WORKDIR /workspace From 0e7e025c5997ef4550c1c1420633176f8cac76d3 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Wed, 5 Mar 2025 15:38:06 -0800 Subject: [PATCH 3/4] use kube-cross to build kms plugin --- staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile | 5 ++++- test/e2e/testing-manifests/auth/encrypt/run-e2e.sh | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile b/staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile index 179ef178c91..035ccdbb8fa 100644 --- a/staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile +++ b/staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile @@ -12,7 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.24.0-bullseye AS builder +# NOTE: this is just a default placeholder for convenience +# To build this image properly, please invoke test/e2e/testing-manifests/auth/encrypt/run-e2e.sh +ARG BUILDER_IMAGE=golang:latest +FROM $BUILDER_IMAGE AS builder WORKDIR /workspace diff --git a/test/e2e/testing-manifests/auth/encrypt/run-e2e.sh b/test/e2e/testing-manifests/auth/encrypt/run-e2e.sh index 7b605adfa57..78f04ef0c61 100755 --- a/test/e2e/testing-manifests/auth/encrypt/run-e2e.sh +++ b/test/e2e/testing-manifests/auth/encrypt/run-e2e.sh @@ -27,6 +27,7 @@ set -o pipefail KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/../../../../.. && pwd -P)" source "${KUBE_ROOT}/hack/lib/init.sh" +source "${KUBE_ROOT}/build/common.sh" readonly cluster_name="kms" readonly registry_name="kind-registry" @@ -38,7 +39,8 @@ build_and_push_mock_plugin() { --no-cache \ --platform linux/amd64 \ --output=type=docker \ - --build-arg=GOTOOLCHAIN="${GOTOOLCHAIN}" \ + --build-arg=GOTOOLCHAIN="${GOTOOLCHAIN:?}" \ + --build-arg=BUILDER_IMAGE="${KUBE_CROSS_IMAGE:?}:${KUBE_CROSS_VERSION:?}" \ -t localhost:5000/mock-kms-provider:e2e \ -f staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile staging/src/k8s.io/ \ --progress=plain; From a1cfb13099d7b585b5004de0ee08616bac12e4e9 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Wed, 5 Mar 2025 17:32:34 -0800 Subject: [PATCH 4/4] we no longer need to track the go version in staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile it is deduped to pull from the build system --- build/dependencies.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/build/dependencies.yaml b/build/dependencies.yaml index ac32cb5b5e4..c02ddecb8b5 100644 --- a/build/dependencies.yaml +++ b/build/dependencies.yaml @@ -137,8 +137,6 @@ dependencies: - path: build/build-image/cross/VERSION - path: hack/lib/golang.sh match: minimum_go_version=go([0-9]+\.[0-9]+) - - path: staging/src/k8s.io/kms/internal/plugins/_mock/Dockerfile - match: golang:([0-9]+\.[0-9]+).0-bullseye - name: "registry.k8s.io/kube-cross: dependents" version: v1.33.0-go1.24.0-bullseye.0