Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete operator CRs in teardown #79

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion scripts/runtime/teardown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a CRD can't be cleanup if the operator does not run and a Central/SecuredCluster instance is tried to be deleted.
At least I failed on this the last time I wanted to add it to the teardown script.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, because of the finalizer? We can solve this via force deletion, but good catch

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which finalizer do you mean?
I had the assumption that the CR can't be deleted because the operator executes the deletion. Therefore if the operator is running the CR can't be deleted.

# 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

Expand Down