From 7161b4db0656495f028136976aa3caef8f609d58 Mon Sep 17 00:00:00 2001 From: Andrei Kvapil Date: Tue, 1 Oct 2024 17:52:07 +0200 Subject: [PATCH] Disable Kamaji default datastore check (#381) Signed-off-by: Andrei Kvapil Signed-off-by: Andrei Kvapil --- .../system/kamaji/images/kamaji/Dockerfile | 26 ++++++++++++++++++- .../patches/disable-datastore-check.diff | 23 ++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 packages/system/kamaji/images/kamaji/patches/disable-datastore-check.diff diff --git a/packages/system/kamaji/images/kamaji/Dockerfile b/packages/system/kamaji/images/kamaji/Dockerfile index e453967e..7946e225 100644 --- a/packages/system/kamaji/images/kamaji/Dockerfile +++ b/packages/system/kamaji/images/kamaji/Dockerfile @@ -1 +1,25 @@ -FROM clastix/kamaji:edge-24.9.2 +# Build the manager binary +FROM golang:1.22 as builder + +ARG VERSION=edge-24.9.2 +ARG TARGETOS TARGETARCH + +WORKDIR /workspace + +RUN curl -sSL https://github.com/clastix/kamaji/archive/refs/tags/${VERSION}.tar.gz | tar -xzvf- --strip=1 + +COPY patches /patches +RUN git apply /patches/disable-datastore-check.diff + +RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build \ + -ldflags "-X github.com/clastix/kamaji/internal.GitRepo=$GIT_REPO -X github.com/clastix/kamaji/internal.GitTag=$GIT_LAST_TAG -X github.com/clastix/kamaji/internal.GitCommit=$GIT_HEAD_COMMIT -X github.com/clastix/kamaji/internal.GitDirty=$GIT_MODIFIED -X github.com/clastix/kamaji/internal.BuildTime=$BUILD_DATE" \ + -a -o kamaji main.go + +# Use distroless as minimal base image to package the manager binary +# Refer to https://github.com/GoogleContainerTools/distroless for more details +FROM gcr.io/distroless/static:nonroot +WORKDIR / +COPY --from=builder /workspace/kamaji . +USER 65532:65532 + +ENTRYPOINT ["/kamaji"] diff --git a/packages/system/kamaji/images/kamaji/patches/disable-datastore-check.diff b/packages/system/kamaji/images/kamaji/patches/disable-datastore-check.diff new file mode 100644 index 00000000..0d28b780 --- /dev/null +++ b/packages/system/kamaji/images/kamaji/patches/disable-datastore-check.diff @@ -0,0 +1,23 @@ +diff --git a/cmd/manager/cmd.go b/cmd/manager/cmd.go +index 9a24d4e..a03a4e0 100644 +--- a/cmd/manager/cmd.go ++++ b/cmd/manager/cmd.go +@@ -31,7 +31,6 @@ import ( + "github.com/clastix/kamaji/controllers/soot" + "github.com/clastix/kamaji/internal" + "github.com/clastix/kamaji/internal/builders/controlplane" +- datastoreutils "github.com/clastix/kamaji/internal/datastore/utils" + "github.com/clastix/kamaji/internal/webhook" + "github.com/clastix/kamaji/internal/webhook/handlers" + "github.com/clastix/kamaji/internal/webhook/routes" +@@ -80,10 +79,6 @@ func NewCmd(scheme *runtime.Scheme) *cobra.Command { + return fmt.Errorf("unable to read webhook CA: %w", err) + } + +- if err = datastoreutils.CheckExists(ctx, scheme, datastore); err != nil { +- return err +- } +- + if controllerReconcileTimeout.Seconds() == 0 { + return fmt.Errorf("the controller reconcile timeout must be greater than zero") + }