Skip to content

Commit 4be8b2d

Browse files
authored
[cluster-autoscaler-release-1.30] update Makefile and Dockerfile (#8689)
* [cluster-autoscaler-release-1.30] update Makefile and Dockerfile * match go version to go version used to build k8s 1.30
1 parent 26b5585 commit 4be8b2d

File tree

5 files changed

+31
-60
lines changed

5 files changed

+31
-60
lines changed

cluster-autoscaler/Dockerfile.amd64 renamed to cluster-autoscaler/Dockerfile

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,20 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
ARG BASEIMAGE=gcr.io/distroless/static:nonroot-amd64
15-
FROM $BASEIMAGE
16-
LABEL maintainer="Marcin Wielgus <[email protected]>"
14+
FROM --platform=$BUILDPLATFORM golang:1.23 as builder
15+
16+
WORKDIR /workspace
17+
18+
COPY . .
19+
20+
ARG GOARCH
21+
ARG LDFLAGS_FLAG
22+
ARG TAGS_FLAG
23+
24+
RUN CGO_ENABLED=0 GOOS=linux go build -o cluster-autoscaler-$GOARCH $LDFLAGS_FLAG $TAGS_FLAG
25+
FROM gcr.io/distroless/static:nonroot
26+
ARG GOARCH
27+
COPY --from=builder /workspace/cluster-autoscaler-$GOARCH /cluster-autoscaler
1728

18-
COPY cluster-autoscaler-amd64 /cluster-autoscaler
1929
WORKDIR /
2030
CMD ["/cluster-autoscaler"]

cluster-autoscaler/Dockerfile.arm64

Lines changed: 0 additions & 20 deletions
This file was deleted.

cluster-autoscaler/Dockerfile.s390x

Lines changed: 0 additions & 20 deletions
This file was deleted.

cluster-autoscaler/Makefile

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
ALL_ARCH = amd64 arm64 s390x
22
all: $(addprefix build-arch-,$(ALL_ARCH))
33

4+
# TODO: #8127 - Use default analyzers set by `go test` to include `printf` analyzer.
5+
# Default analyzers that go test runs according to https://github.com/golang/go/blob/52624e533fe52329da5ba6ebb9c37712048168e0/src/cmd/go/internal/test/test.go#L649
6+
# This doesn't include the `printf` analyzer until cluster-autoscaler libraries are updated.
7+
GO_TEST_DEFAULT_ANALYZERS?=atomic,bool,buildtags,directive,errorsas,ifaceassert,nilfunc,slog,stringintconv,tests
48
TAG?=dev
59
FLAGS=
610
LDFLAGS?=-s
711
ENVVAR=CGO_ENABLED=0
812
GOOS?=linux
913
GOARCH?=$(shell go env GOARCH)
10-
REGISTRY?=staging-k8s.gcr.io
14+
REGISTRY?=gcr.io/k8s-staging-autoscaling
1115
DOCKER_NETWORK?=default
1216
SUPPORTED_BUILD_TAGS=$(shell ls cloudprovider/builder/ | grep -e '^builder_.*\.go' | sed 's/builder_\(.*\)\.go/\1/')
1317
ifdef BUILD_TAGS
@@ -20,7 +24,7 @@ else
2024
FOR_PROVIDER=
2125
endif
2226
ifdef LDFLAGS
23-
LDFLAGS_FLAG=--ldflags "${LDFLAGS}"
27+
LDFLAGS_FLAG=--ldflags="${LDFLAGS}"
2428
else
2529
LDFLAGS_FLAG=
2630
endif
@@ -38,8 +42,6 @@ IMAGE=$(REGISTRY)/cluster-autoscaler$(PROVIDER)
3842
export DOCKER_CLI_EXPERIMENTAL := enabled
3943

4044
build:
41-
@echo "⚠️ WARNING: The vendor directory will be removed soon. \
42-
Please make sure your dependencies are managed via Go modules."
4345
@$(MAKE) build-arch-$(GOARCH)
4446

4547
build-arch-%: clean-arch-%
@@ -56,7 +58,7 @@ test-build-tags:
5658
done
5759

5860
test-unit: clean build
59-
go test --test.short -race ./... ${TAGS_FLAG}
61+
go test --test.short -race ./... -vet="${GO_TEST_DEFAULT_ANALYZERS}" ${TAGS_FLAG}
6062

6163
dev-release: dev-release-arch-$(GOARCH)
6264

@@ -66,28 +68,27 @@ dev-release-arch-%: build-arch-% make-image-arch-% push-image-arch-%
6668
make-image: make-image-arch-$(GOARCH)
6769

6870
make-image-arch-%:
69-
ifdef BASEIMAGE
70-
docker build --pull --build-arg BASEIMAGE=${BASEIMAGE} \
71+
GOOS=$(GOOS) docker buildx build --pull --platform linux/$* \
72+
--build-arg "GOARCH=$*" \
73+
--provenance=false \
7174
-t ${IMAGE}-$*:${TAG} \
72-
-f Dockerfile.$* .
73-
else
74-
docker build --pull \
75-
-t ${IMAGE}-$*:${TAG} \
76-
-f Dockerfile.$* .
77-
endif
75+
-f Dockerfile .
7876
@echo "Image ${TAG}${FOR_PROVIDER}-$* completed"
7977

8078
push-image: push-image-arch-$(GOARCH)
8179

8280
push-image-arch-%:
8381
./push_image.sh ${IMAGE}-$*:${TAG}
8482

83+
push-release-image-arch-%:
84+
docker push ${IMAGE}-$*:${TAG}
85+
8586
push-manifest:
8687
docker manifest create ${IMAGE}:${TAG} \
8788
$(addprefix $(REGISTRY)/cluster-autoscaler$(PROVIDER)-, $(addsuffix :$(TAG), $(ALL_ARCH)))
8889
docker manifest push --purge ${IMAGE}:${TAG}
8990

90-
execute-release: $(addprefix make-image-arch-,$(ALL_ARCH)) $(addprefix push-image-arch-,$(ALL_ARCH)) push-manifest
91+
execute-release: $(addprefix make-image-arch-,$(ALL_ARCH)) $(addprefix push-release-image-arch-,$(ALL_ARCH)) push-manifest
9192
@echo "Release ${TAG}${FOR_PROVIDER} completed"
9293

9394
clean: clean-arch-$(GOARCH)
@@ -133,7 +134,7 @@ container-arch-%: build-in-docker-arch-% make-image-arch-%
133134
@echo "Full in-docker image ${TAG}${FOR_PROVIDER}-$* completed"
134135

135136
test-in-docker: clean docker-builder
136-
docker run ${RM_FLAG} -v `pwd`:/cluster-autoscaler/:Z autoscaling-builder:latest bash -c 'cd /cluster-autoscaler && go test -race ./... ${TAGS_FLAG}'
137+
docker run ${RM_FLAG} -v `pwd`:/cluster-autoscaler/:Z autoscaling-builder:latest bash -c 'cd /cluster-autoscaler && go test -race ./... -vet="${GO_TEST_DEFAULT_ANALYZERS}" ${TAGS_FLAG}'
137138

138139
.PHONY: all build test-unit clean format execute-release dev-release docker-builder build-in-docker release generate push-image push-manifest
139140

cluster-autoscaler/cloudprovider/externalgrpc/examples/external-grpc-cloud-provider-service/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LDFLAGS?=-s
77
ENVVAR=CGO_ENABLED=0
88
GOOS?=linux
99
GOARCH?=$(shell go env GOARCH)
10-
REGISTRY?=staging-k8s.gcr.io
10+
REGISTRY?=gcr.io/k8s-staging-autoscaling
1111
DOCKER_NETWORK?=default
1212
ifdef BUILD_TAGS
1313
TAGS_FLAG=--tags ${BUILD_TAGS}

0 commit comments

Comments
 (0)