From 5199b561aa54f9f3ff5f31d9556f5c1e1ce12a80 Mon Sep 17 00:00:00 2001 From: Dean Roehrich Date: Wed, 15 Nov 2023 15:27:59 -0600 Subject: [PATCH] Delete the ServiceMonitor CR only if its CRD exists Signed-off-by: Dean Roehrich --- deploy.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index 47b9636ab..ec793b5cf 100755 --- a/deploy.sh +++ b/deploy.sh @@ -65,7 +65,9 @@ if [[ $CMD == 'deploy' ]]; then fi if [[ $CMD == 'undeploy' ]]; then - $KUSTOMIZE build config/prometheus | kubectl delete --ignore-not-found -f- + if kubectl get crd servicemonitors.monitoring.coreos.com > /dev/null 2>&1; then + $KUSTOMIZE build config/prometheus | kubectl delete --ignore-not-found -f- + fi $KUSTOMIZE build config/ports | kubectl delete --ignore-not-found -f - $KUSTOMIZE build $OVERLAY_EXAMPLES_DIR | kubectl delete --ignore-not-found -f - $KUSTOMIZE build $OVERLAY_DIR | kubectl delete --ignore-not-found -f -