From bd95a5e02005aeb0b0d8a6316369ed998f1b4d82 Mon Sep 17 00:00:00 2001 From: Malte Isberner Date: Wed, 20 Oct 2021 22:20:08 +0200 Subject: [PATCH 1/2] delete operator CRs in teardown --- scripts/runtime/teardown.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/runtime/teardown.sh b/scripts/runtime/teardown.sh index 38ee1f7..62ecf60 100755 --- a/scripts/runtime/teardown.sh +++ b/scripts/runtime/teardown.sh @@ -50,7 +50,12 @@ kubectl -n stackrox delete --grace-period=0 --force deploy/central deploy/sensor kubectl -n stackrox get application -o name | xargs kubectl -n stackrox delete --wait # DO NOT ADD ANY NON-NAMESPACED RESOURCES TO THIS LIST, OTHERWISE ALL RESOURCES IN THE CLUSTER OF THAT TYPE # WILL BE DELETED! -kubectl -n stackrox get cm,deploy,ds,hpa,networkpolicy,role,rolebinding,secret,svc,serviceaccount,pvc -o name | xargs kubectl -n stackrox delete --wait +{ + kubectl -n stackrox get cm,deploy,ds,hpa,networkpolicy,role,rolebinding,secret,svc,serviceaccount,pvc -o name + # Delete operator CRs. This is broken out into a separate invocation, as the entire command fails + # if the CRDs are not available + kubectl -n stackrox get central.platform.stackrox.io,securedcluster.platform.stackrox.io -o name 2>/dev/null +} | xargs kubectl -n stackrox delete --wait # Only delete cluster-wide RBAC/PSP-related resources that contain have the app.kubernetes.io/name=stackrox label. kubectl -n stackrox get clusterrole,clusterrolebinding,psp,validatingwebhookconfiguration -o name -l app.kubernetes.io/name=stackrox | xargs kubectl -n stackrox delete --wait From eb483873379ac82679fa83833bcd8ee8503d77df Mon Sep 17 00:00:00 2001 From: Malte Isberner Date: Wed, 20 Oct 2021 23:09:17 +0200 Subject: [PATCH 2/2] or true --- scripts/runtime/teardown.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/runtime/teardown.sh b/scripts/runtime/teardown.sh index 62ecf60..36b2b49 100755 --- a/scripts/runtime/teardown.sh +++ b/scripts/runtime/teardown.sh @@ -54,7 +54,7 @@ kubectl -n stackrox get application -o name | xargs kubectl -n stackrox delete - kubectl -n stackrox get cm,deploy,ds,hpa,networkpolicy,role,rolebinding,secret,svc,serviceaccount,pvc -o name # Delete operator CRs. This is broken out into a separate invocation, as the entire command fails # if the CRDs are not available - kubectl -n stackrox get central.platform.stackrox.io,securedcluster.platform.stackrox.io -o name 2>/dev/null + kubectl -n stackrox get central.platform.stackrox.io,securedcluster.platform.stackrox.io -o name 2>/dev/null || true } | xargs kubectl -n stackrox delete --wait # Only delete cluster-wide RBAC/PSP-related resources that contain have the app.kubernetes.io/name=stackrox label. kubectl -n stackrox get clusterrole,clusterrolebinding,psp,validatingwebhookconfiguration -o name -l app.kubernetes.io/name=stackrox | xargs kubectl -n stackrox delete --wait