From eb03484d56309a7c31bb953e14190a66648a839b Mon Sep 17 00:00:00 2001 From: Nikolai Rodionov Date: Wed, 3 Apr 2024 09:50:45 +0200 Subject: [PATCH] Update scripts and templates --- hooks/down.sh | 10 +++++++++- hooks/up.sh | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hooks/down.sh b/hooks/down.sh index 7e542d0..370ad97 100755 --- a/hooks/down.sh +++ b/hooks/down.sh @@ -7,6 +7,7 @@ kubernetes: - name: Watch bootstrap configmaps getting removed apiVersion: v1 kind: ConfigMap + executeHookOnSynchronization: false executeHookOnEvent: ["Modified"] jqFilter: ".metadata.deletionTimestamp" labelSelector: @@ -18,13 +19,20 @@ EOF else PROVIDER=$(jq -r .[0].objects.[0].object.data.provider $BINDING_CONTEXT_PATH) KUBERNETES=$(jq -r .[0].objects.[0].object.data.kubernetes $BINDING_CONTEXT_PATH) + echo "running the ${PROVIDER}-cleanup hook" + if ! [ -f /tpls/${PROVIDER}-cleanup.yaml ]; then - echo "ERROR: template not found for ${PROVIDER}-cleanup" + echo "template not found for ${PROVIDER}-cleanup" exit 1 fi + export SP_CUSTOMER_ID=$(jq -r .[0].objects.[0].object.metadata.namespace $BINDING_CONTEXT_PATH) export SP_ENVIRONMENT=$(jq -r .[0].objects.[0].object.metadata.name $BINDING_CONTEXT_PATH) + echo "removing the ${SP_ENVIRONMENT} owned by ${SP_CUSTOMER_ID}" + envsubst < /tpls/${PROVIDER}-cleanup.yaml | kubectl create -f - + + # -- Removing the finalizer kubectl patch configmap -n ${SP_CUSTOMER_ID} ${SP_ENVIRONMENT} \ -p '{"metadata":{"finalizers":null}}' --type=merge fi diff --git a/hooks/up.sh b/hooks/up.sh index 2587c66..ee63685 100755 --- a/hooks/up.sh +++ b/hooks/up.sh @@ -12,6 +12,7 @@ kubernetes: - name: Watch bootstrap configmaps getting created apiVersion: v1 kind: ConfigMap + executeHookOnSynchronization: false executeHookOnEvent: ["Added", "Modified"] jqFilter: ".data" labelSelector: