Add Templates to pretty config

This commit is contained in:
Nikolai Rodionov 2024-05-10 13:18:06 +02:00
parent 815ae64e32
commit 629bb23a79
Signed by: allanger
GPG Key ID: 0AA46A90E25592AD
2 changed files with 21 additions and 1 deletions

View File

@ -1,4 +1,9 @@
FROM fluxcd/flux-cli as flux-source
WORKDIR /out
RUN cp $(which flux) .
FROM ghcr.io/flant/shell-operator:latest FROM ghcr.io/flant/shell-operator:latest
RUN apk update && apk add envsubst --no-cache RUN apk update && apk add envsubst --no-cache
COPY --from=flux-source /out/flux /usr/bin/flux
ADD /hooks /hooks ADD /hooks /hooks
ADD /tpls /tpls ADD /tpls /tpls

View File

@ -26,6 +26,21 @@ else
export SP_CUSTOMER_ID=$(jq -r .[0].object.metadata.namespace $BINDING_CONTEXT_PATH) 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_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') 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 fi