Update scripts and templates

This commit is contained in:
Nikolai Rodionov 2024-04-03 09:50:45 +02:00
parent d4be11fd65
commit eb03484d56
Signed by: allanger
GPG Key ID: 0AA46A90E25592AD
2 changed files with 10 additions and 1 deletions

View File

@ -7,6 +7,7 @@ kubernetes:
- name: Watch bootstrap configmaps getting removed - name: Watch bootstrap configmaps getting removed
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
executeHookOnSynchronization: false
executeHookOnEvent: ["Modified"] executeHookOnEvent: ["Modified"]
jqFilter: ".metadata.deletionTimestamp" jqFilter: ".metadata.deletionTimestamp"
labelSelector: labelSelector:
@ -18,13 +19,20 @@ EOF
else else
PROVIDER=$(jq -r .[0].objects.[0].object.data.provider $BINDING_CONTEXT_PATH) PROVIDER=$(jq -r .[0].objects.[0].object.data.provider $BINDING_CONTEXT_PATH)
KUBERNETES=$(jq -r .[0].objects.[0].object.data.kubernetes $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 if ! [ -f /tpls/${PROVIDER}-cleanup.yaml ]; then
echo "ERROR: template not found for ${PROVIDER}-cleanup" echo "template not found for ${PROVIDER}-cleanup"
exit 1 exit 1
fi fi
export SP_CUSTOMER_ID=$(jq -r .[0].objects.[0].object.metadata.namespace $BINDING_CONTEXT_PATH) 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) 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 - envsubst < /tpls/${PROVIDER}-cleanup.yaml | kubectl create -f -
# -- Removing the finalizer
kubectl patch configmap -n ${SP_CUSTOMER_ID} ${SP_ENVIRONMENT} \ kubectl patch configmap -n ${SP_CUSTOMER_ID} ${SP_ENVIRONMENT} \
-p '{"metadata":{"finalizers":null}}' --type=merge -p '{"metadata":{"finalizers":null}}' --type=merge
fi fi

View File

@ -12,6 +12,7 @@ kubernetes:
- name: Watch bootstrap configmaps getting created - name: Watch bootstrap configmaps getting created
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
executeHookOnSynchronization: false
executeHookOnEvent: ["Added", "Modified"] executeHookOnEvent: ["Added", "Modified"]
jqFilter: ".data" jqFilter: ".data"
labelSelector: labelSelector: