From 629bb23a79b0466d6d4d4280d998a3608e4e3a0f Mon Sep 17 00:00:00 2001 From: Nikolai Rodionov Date: Fri, 10 May 2024 13:18:06 +0200 Subject: [PATCH] Add Templates to pretty config --- Containerfile | 5 +++++ hooks/install-application.sh | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Containerfile b/Containerfile index 55a4a47..d2eed42 100644 --- a/Containerfile +++ b/Containerfile @@ -1,4 +1,9 @@ +FROM fluxcd/flux-cli as flux-source +WORKDIR /out +RUN cp $(which flux) . + FROM ghcr.io/flant/shell-operator:latest RUN apk update && apk add envsubst --no-cache +COPY --from=flux-source /out/flux /usr/bin/flux ADD /hooks /hooks ADD /tpls /tpls diff --git a/hooks/install-application.sh b/hooks/install-application.sh index dc3da91..e68d2e4 100755 --- a/hooks/install-application.sh +++ b/hooks/install-application.sh @@ -26,6 +26,21 @@ else export SP_CUSTOMER_ID=$(jq -r .[0].object.metadata.namespace $BINDING_CONTEXT_PATH) export SP_ENVIRONMENT=$(jq -r .[0].object.metadata.name $BINDING_CONTEXT_PATH) export SP_APPLICATION=$(jq -r .[0].object.data.values $BINDING_CONTEXT_PATH | base64 -d | yq '.helm.release') - envsubst < /tpls/flux-create.yaml | kubectl create -f - + + flux create source helm $SP_APPLICATION \ + --namespace=$SP_ACCOUNT \ + --url=oci://registry.badhouseplants.net/softplayer/helm + + flux create helmrelease $SP_APPLICATION \ + --source=HelmRepository/$SP_APPLICATION \ + --namespace=$SP_CUSTOMER_ID \ + --chart=helmrelease \ + --values-from Secret/$SP_APPLICATION \ + --kubeconfig-secret-ref=$SP_CUSTOMER_ID-config \ + --target-namespace=default --export \ + | yq '.spec.storageNamespace="helm-installations"' \ + | kubectl create -f - + flux reconcile helmrelease --namespace=$SP_ACCOUNT $SP_APPLICATION + fi