fixes for issues in capi-garbage-cleanup.sh
This MR fixes two issues:
-
cluster CAPI garbage collector removes XXXConfi... (#871 - closed) - this issue was due to the use of Kinds with a plural in one place and singular in another place (what is returned by
kubectl get
here for instance) - my understanding is that this issue was likely impacting other resources - the use of
VSphereMachineTemplates.cluster.x-k8s.io
instead ofVSphereMachineTemplates.infrastructure.cluster.x-k8s.io
inkubectl get
(after the transformation ofVSphereMachineTemplates.*cluster.x-k8s.io
byVSphereMachineTemplates.cluster.x-k8s.io
here): this issue was due possibly went unoticed - although the use of a fully-qualified resource kind is necessary only for VSphereMachineTemplates (without a fully-qualified name we would "collide" with a same-named cattle.io CRD), I opted for using fully-qualified names for all resources looked at by the script so that we can validate the code including on non-capv deployments
Additionally, I did two improvements:
- add a safeguard so that we never delete a resource that still has ownerReferences
- generate a Kubernetes event on deletion -- this may help us in the future
/cc @baburciu
Edited by Thomas Morin