Skip to content

Commit

Permalink
fix: bump vpa + update container builds
Browse files Browse the repository at this point in the history
Signed-off-by: David van der Spek <[email protected]>
  • Loading branch information
davidspek committed Dec 2, 2024
1 parent 3230edb commit 7321b16
Show file tree
Hide file tree
Showing 30 changed files with 284 additions and 136 deletions.
2 changes: 1 addition & 1 deletion multidimensional-pod-autoscaler/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
golang.org/x/time v0.4.0
k8s.io/api v0.31.3
k8s.io/apimachinery v0.31.3
k8s.io/autoscaler/vertical-pod-autoscaler v1.1.2
k8s.io/autoscaler/vertical-pod-autoscaler v1.2.1
k8s.io/client-go v0.31.3
k8s.io/code-generator v0.31.3
k8s.io/component-base v0.31.3
Expand Down
4 changes: 2 additions & 2 deletions multidimensional-pod-autoscaler/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ k8s.io/apimachinery v0.31.3 h1:6l0WhcYgasZ/wk9ktLq5vLaoXJJr5ts6lkaQzgeYPq4=
k8s.io/apimachinery v0.31.3/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo=
k8s.io/apiserver v0.31.3 h1:+1oHTtCB+OheqFEz375D0IlzHZ5VeQKX1KGXnx+TTuY=
k8s.io/apiserver v0.31.3/go.mod h1:PrxVbebxrxQPFhJk4powDISIROkNMKHibTg9lTRQ0Qg=
k8s.io/autoscaler/vertical-pod-autoscaler v1.1.2 h1:ENxmnVXLt8+iXhDA0PNFhXb1sgvbvnAc66sC34UGrTw=
k8s.io/autoscaler/vertical-pod-autoscaler v1.1.2/go.mod h1:J2cNKnieE7r4bInjpQDBq93D50aD/CmspSi6xRUfKk4=
k8s.io/autoscaler/vertical-pod-autoscaler v1.2.1 h1:t5t0Rsn4b7iQfiVlGdWSEnEx8pjrSM96Sn4Dvo1QH/Q=
k8s.io/autoscaler/vertical-pod-autoscaler v1.2.1/go.mod h1:9ywHbt0kTrLyeNGgTNm7WEns34PmBMEr+9bDKTxW6wQ=
k8s.io/client-go v0.31.3 h1:CAlZuM+PH2cm+86LOBemaJI/lQ5linJ6UFxKX/SoG+4=
k8s.io/client-go v0.31.3/go.mod h1:2CgjPUTpv3fE5dNygAr2NcM8nhHzXvxB8KL5gYc3kJs=
k8s.io/cloud-provider v0.31.3 h1:7C3CHQUUwnv/HWWVIaibZH06iPg663RYQ6C6Zy4FnO8=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func main() {
kube_flag.InitFlags()
klog.V(1).Infof("Multi-dimensional Pod Autoscaler %s Admission Controller", common.MultidimPodAutoscalerVersion)

healthCheck := metrics.NewHealthCheck(time.Minute, false)
healthCheck := metrics.NewHealthCheck(time.Minute)
metrics.Initialize(*address, healthCheck)
metrics_admission.Register()

Expand Down
21 changes: 16 additions & 5 deletions multidimensional-pod-autoscaler/pkg/recommender/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 The Kubernetes Authors. All rights reserved
# Copyright 2017 The Kubernetes Authors. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,11 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM --platform=$BUILDPLATFORM golang:1.23.3 AS builder

ENV GOPATH=/gopath/
ENV PATH=$GOPATH/bin:$PATH

COPY . /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler
WORKDIR /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler

ARG TARGETOS TARGETARCH

RUN CGO_ENABLED=0 LD_FLAGS=-s GOARCH=$TARGETARCH GOOS=$TARGETOS go build -C pkg/recommender -mod vendor -o recommender-$TARGETARCH

FROM gcr.io/distroless/static:latest
MAINTAINER Krzysztof Grygiel "[email protected]"

ARG ARCH
COPY recommender-$ARCH /recommender
ARG TARGETARCH

COPY --from=builder /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler/pkg/recommender/recommender-$TARGETARCH /recommender

ENTRYPOINT ["/recommender"]
CMD ["--v=4", "--stderrthreshold=info", "--prometheus-address=http://prometheus.monitoring.svc"]
41 changes: 20 additions & 21 deletions multidimensional-pod-autoscaler/pkg/recommender/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ ENVVAR=CGO_ENABLED=0 $(TEST_ENVVAR)
GOOS?=linux
COMPONENT=recommender
FULL_COMPONENT=mpa-${COMPONENT}
# localhost registries need --insecure for some docker commands.
INSECURE=$(subst localhost,--insecure,$(findstring localhost,$(REGISTRY)))

ALL_ARCHITECTURES?=amd64 arm arm64 ppc64le s390x
export DOCKER_CLI_EXPERIMENTAL=enabled
Expand All @@ -19,21 +21,14 @@ build: clean
build-binary: clean
$(ENVVAR) GOOS=$(GOOS) go build -o ${COMPONENT}

.PHONY: build-binary-with-vendor
build-binary-with-vendor: $(addprefix build-binary-with-vendor-,$(ALL_ARCHITECTURES)) clean

.PHONY: build-binary-with-vendor-*
build-binary-with-vendor-%:
$(ENVVAR) GOARCH=$* GOOS=$(GOOS) go build -mod vendor -o ${COMPONENT}-$*

test-unit: clean build
$(TEST_ENVVAR) go test --test.short -race ./... $(FLAGS)

.PHONY: docker-build
docker-build: $(addprefix docker-build-,$(ALL_ARCHITECTURES))

.PHONY: docker-build-*
docker-build-%:
docker-build-%:
ifndef REGISTRY
ERR = $(error REGISTRY is undefined)
$(ERR)
Expand All @@ -42,13 +37,10 @@ ifndef TAG
ERR = $(error TAG is undefined)
$(ERR)
endif
docker build --pull -t ${REGISTRY}/${FULL_COMPONENT}-$*:${TAG} --build-arg ARCH=$* .
docker buildx build --pull --load --platform linux/$* -t ${REGISTRY}/${FULL_COMPONENT}-$*:${TAG} -f ./Dockerfile ../../

.PHONY: docker-push
docker-push: $(addprefix sub-push-,$(ALL_ARCHITECTURES)) push-multi-arch;

.PHONY: sub-push-*
sub-push-%: docker-build-% do-push-% ;
docker-push: $(addprefix do-push-,$(ALL_ARCHITECTURES)) push-multi-arch;

.PHONY: do-push-*
do-push-%:
Expand All @@ -68,17 +60,24 @@ push-multi-arch:
@for arch in $(ALL_ARCHITECTURES); do docker manifest annotate --arch $${arch} $(REGISTRY)/${FULL_COMPONENT}:$(TAG) $(REGISTRY)/${FULL_COMPONENT}-$${arch}:${TAG}; done
docker manifest push --purge $(REGISTRY)/${FULL_COMPONENT}:$(TAG)

docker-builder:
docker build -t mpa-autoscaling-builder ../../builder
.PHONY: show-git-info
show-git-info:
echo '=============== local git status ==============='
git status
echo '=============== last commit ==============='
git log -1
echo '=============== bulding from the above ==============='

.PHONY: build-in-docker
build-in-docker: $(addprefix build-in-docker-,$(ALL_ARCHITECTURES))
.PHONY: create-buildx-builder
create-buildx-builder:
BUILDER=$(shell docker buildx create --driver=docker-container --use)

.PHONY: build-in-docker-*
build-in-docker-%: clean docker-builder
docker run -v `pwd`/../..:/gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler mpa-autoscaling-builder:latest bash -c 'cd /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler && make build-binary-with-vendor-$* -C pkg/recommender'
.PHONY: remove-buildx-builder
remove-buildx-builder:
docker buildx rm ${BUILDER}

release: build-in-docker docker-build docker-push
.PHONY: release
release: show-git-info create-buildx-builder docker-build remove-buildx-builder docker-push
@echo "Full in-docker release ${FULL_COMPONENT}:${TAG} completed"

clean: $(addprefix clean-,$(ALL_ARCHITECTURES))
Expand Down
2 changes: 1 addition & 1 deletion multidimensional-pod-autoscaler/pkg/recommender/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func main() {

vpa_model.InitializeAggregationsConfig(vpa_model.NewAggregationsConfig(*memoryAggregationInterval, *memoryAggregationIntervalCount, *memoryHistogramDecayHalfLife, *cpuHistogramDecayHalfLife, *oomBumpUpRatio, *oomMinBumpUp))

healthCheck := metrics.NewHealthCheck(*metricsFetcherInterval*5, true)
healthCheck := metrics.NewHealthCheck(*metricsFetcherInterval * 5)
metrics.Initialize(*address, healthCheck)
metrics_recommender.Register()
metrics_quality.Register()
Expand Down
20 changes: 15 additions & 5 deletions multidimensional-pod-autoscaler/pkg/updater/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 The Kubernetes Authors. All rights reserved
# Copyright 2016 The Kubernetes Authors. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,12 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM --platform=$BUILDPLATFORM golang:1.23.3 AS builder

ENV GOPATH=/gopath/
ENV PATH=$GOPATH/bin:$PATH

COPY . /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler
WORKDIR /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler

ARG TARGETOS TARGETARCH

RUN CGO_ENABLED=0 LD_FLAGS=-s GOARCH=$TARGETARCH GOOS=$TARGETOS go build -C pkg/updater -mod vendor -o updater-$TARGETARCH

FROM gcr.io/distroless/static:latest
MAINTAINER Marcin Wielgus "[email protected]"

ARG ARCH
COPY updater-$ARCH /updater
ARG TARGETARCH

COPY --from=builder /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler/pkg/updater/updater-$TARGETARCH /updater

ENTRYPOINT ["/updater"]
CMD ["--v=4", "--stderrthreshold=info"]
36 changes: 16 additions & 20 deletions multidimensional-pod-autoscaler/pkg/updater/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ build: clean
build-binary: clean
$(ENVVAR) GOOS=$(GOOS) go build -o ${COMPONENT}

.PHONY: build-binary-with-vendor
build-binary-with-vendor: $(addprefix build-binary-with-vendor-,$(ALL_ARCHITECTURES)) clean

.PHONY: build-binary-with-vendor-*
build-binary-with-vendor-%:
$(ENVVAR) GOARCH=$* GOOS=$(GOOS) go build -mod vendor -o ${COMPONENT}-$*

test-unit: clean build
$(TEST_ENVVAR) go test --test.short -race ./... $(FLAGS)

Expand All @@ -42,13 +35,10 @@ ifndef TAG
ERR = $(error TAG is undefined)
$(ERR)
endif
docker build --pull -t ${REGISTRY}/${FULL_COMPONENT}-$*:${TAG} --build-arg ARCH=$* .
docker buildx build --pull --load --platform linux/$* -t ${REGISTRY}/${FULL_COMPONENT}-$*:${TAG} -f ./Dockerfile ../../

.PHONY: docker-push
docker-push: $(addprefix sub-push-,$(ALL_ARCHITECTURES)) push-multi-arch;

.PHONY: sub-push-*
sub-push-%: docker-build-% do-push-% ;
docker-push: $(addprefix do-push-,$(ALL_ARCHITECTURES)) push-multi-arch;

.PHONY: do-push-*
do-push-%:
Expand All @@ -68,18 +58,24 @@ push-multi-arch:
@for arch in $(ALL_ARCHITECTURES); do docker manifest annotate --arch $${arch} $(REGISTRY)/${FULL_COMPONENT}:$(TAG) $(REGISTRY)/${FULL_COMPONENT}-$${arch}:${TAG}; done
docker manifest push --purge $(REGISTRY)/${FULL_COMPONENT}:$(TAG)

docker-builder:
docker build -t vpa-autoscaling-builder ../../builder
.PHONY: show-git-info
show-git-info:
echo '=============== local git status ==============='
git status
echo '=============== last commit ==============='
git log -1
echo '=============== bulding from the above ==============='

.PHONY: build-in-docker
build-in-docker: $(addprefix build-in-docker-,$(ALL_ARCHITECTURES))
.PHONY: create-buildx-builder
create-buildx-builder:
BUILDER=$(shell docker buildx create --driver=docker-container --use)

.PHONY: build-in-docker-*
build-in-docker-%: clean docker-builder
docker run -v `pwd`/../..:/gopath/src/k8s.io/autoscaler/vertical-pod-autoscaler vpa-autoscaling-builder:latest bash -c 'cd /gopath/src/k8s.io/autoscaler/vertical-pod-autoscaler && make build-binary-with-vendor-$* -C pkg/updater'
.PHONY: remove-buildx-builder
remove-buildx-builder:
docker buildx rm ${BUILDER}

.PHONY: release
release: build-in-docker docker-build docker-push
release: show-git-info create-buildx-builder docker-build remove-buildx-builder docker-push
@echo "Full in-docker release ${FULL_COMPONENT}:${TAG} completed"

clean: $(addprefix clean-,$(ALL_ARCHITECTURES))
Expand Down
2 changes: 1 addition & 1 deletion multidimensional-pod-autoscaler/pkg/updater/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func main() {
kube_flag.InitFlags()
klog.V(1).Infof("Multidimensional Pod Autoscaler %s Updater", common.MultidimPodAutoscalerVersion)

healthCheck := metrics.NewHealthCheck(*updaterInterval*5, true)
healthCheck := metrics.NewHealthCheck(*updaterInterval * 5)
metrics.Initialize(*address, healthCheck)
metrics_updater.Register()

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7321b16

Please sign in to comment.