From cb8963ad92952e62f0dd285309c6d6f38efaf668 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Tue, 20 Jan 2026 21:43:36 -0500 Subject: [PATCH] Fix sample-apiserver image build failure The kube-cross image has GOPATH=/usr/local/go and GOROOT=/usr/local/go (same directory). When `go install .` runs, the binary is placed in /usr/local/go/bin/, but the Makefile was searching for it in /go/bin/ which is empty. Fix by using `go build -o` to place the binary directly at the target location instead of relying on go install + find. Signed-off-by: Davanum Srinivas --- test/images/sample-apiserver/Makefile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test/images/sample-apiserver/Makefile b/test/images/sample-apiserver/Makefile index 165ab97839f..d3b52dd56a6 100644 --- a/test/images/sample-apiserver/Makefile +++ b/test/images/sample-apiserver/Makefile @@ -27,15 +27,11 @@ export bin: docker run --rm -i -v "${TARGET}:${TARGET}:Z" registry.k8s.io/build-image/kube-cross:${KUBE_CROSS_VERSION} \ /bin/bash -c "\ - mkdir -p /go/src /go/bin && \ + mkdir -p /go/src && \ git clone https://github.com/kubernetes/sample-apiserver /go/src/k8s.io/sample-apiserver && \ cd /go/src/k8s.io/sample-apiserver && \ git checkout tags/v0.33.7 && \ go mod tidy && \ - GO111MODULE=on CGO_ENABLED=0 GOARM=${GOARM} GOOS=${OS} GOARCH=${ARCH} go install . && \ - find /go/bin -name sample-apiserver* -exec cp {} ${TARGET}/sample-apiserver \;" - # for arm, go install uses /go/bin/linux_arm, so just find the file and copy it to the - # root so we can copy it out from this throw away container image from a standard location. - # Windows executables have .exe extension, which is why we're searching sample-apiserver* + GO111MODULE=on CGO_ENABLED=0 GOARM=${GOARM} GOOS=${OS} GOARCH=${ARCH} go build -o ${TARGET}/sample-apiserver ." .PHONY: bin