From 5047dc1b029525f5cc82456a53baf917fdc59d83 Mon Sep 17 00:00:00 2001 From: vsoch Date: Sun, 6 Oct 2024 16:12:38 -0600 Subject: [PATCH] build: add custom scheduler Dockerfile Problem: the sig-scheduler-plugins Dockerfile was updated to use a distroless image over alpine, and this destroyed our logging strategy so it was impossible to see printed messages from fluence. Since this has bit us before, it will be a simpler strategy moving forward to put this build under our control, and resort back to using the previous alpine base. Solution: add the src/build/scheduler/Dockerfile to our maintained files, and ensure we use an alpine base that has a filesystem. Signed-off-by: vsoch --- Makefile | 2 ++ .../build/scheduler/Dockerfile | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 sig-scheduler-plugins/build/scheduler/Dockerfile diff --git a/Makefile b/Makefile index ad9b370..273e8c0 100644 --- a/Makefile +++ b/Makefile @@ -37,11 +37,13 @@ prepare: clone # These are entirely new directory structures rm -rf $(CLONE_UPSTREAM)/pkg/fluence rm -rf $(CLONE_UPSTREAM)/pkg/logger + rm -rf $(CLONE_UPSTREAM)/build/scheduler # rm -rf $(CLONE_UPSTREAM)/cmd/app rm -rf $(CLONE_UPSTREAM)/pkg/controllers/podgroup_controller.go rm -rf $(CLONE_UPSTREAM)/cmd/controller/app/server.go cp -R sig-scheduler-plugins/pkg/logger $(CLONE_UPSTREAM)/pkg/logger cp -R sig-scheduler-plugins/pkg/fluence $(CLONE_UPSTREAM)/pkg/fluence + cp -R sig-scheduler-plugins/build/scheduler $(CLONE_UPSTREAM)/build/scheduler cp -R sig-scheduler-plugins/pkg/controllers/* $(CLONE_UPSTREAM)/pkg/controllers/ # This is the one exception not from sig-scheduler-plugins because it is needed in both spots cp -R src/fluence/fluxcli-grpc $(CLONE_UPSTREAM)/pkg/fluence/fluxcli-grpc diff --git a/sig-scheduler-plugins/build/scheduler/Dockerfile b/sig-scheduler-plugins/build/scheduler/Dockerfile new file mode 100644 index 0000000..fbbd96a --- /dev/null +++ b/sig-scheduler-plugins/build/scheduler/Dockerfile @@ -0,0 +1,32 @@ +# Copyright 2020 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +ARG GO_BASE_IMAGE=golang +ARG DISTROLESS_BASE_IMAGE=gcr.io/distroless/static:nonroot +FROM --platform=${BUILDPLATFORM} $GO_BASE_IMAGE AS builder + +WORKDIR /workspace +COPY . . +ARG TARGETARCH +RUN make build-scheduler GO_BUILD_ENV='CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH}' && \ + cp /workspace/bin/kube-scheduler /bin/kube-scheduler + +# Disable distroless because we are wanting a filesystem to preserve logs, etc. +FROM alpine:3.20 +# FROM --platform=${BUILDPLATFORM} $DISTROLESS_BASE_IMAGE + +WORKDIR /bin +COPY --from=builder /workspace/bin/kube-scheduler . +USER 65532:65532 + +ENTRYPOINT ["/bin/kube-scheduler"]