Delete namespace and all its contents

Is there a way to delete entire namespace and all the contents in the namespace such as checks, handlers, users associated with the namespace via a single sensuctl command.

Currently trying to clear a namespace with some items requires to individually clear out the various elements which can be tedious before we can run the sensuctl namespace delete xyz command.

You might be able to dump that namespace to a file then use sensuctl delete -f

1 Like

sensuctl has a few mechanisms for doing that, you can use the delete method which works, I might suggest looking at the newer prune method as well.

This is a good way to delete the regular checks and handlers but with users created in the namespace, the dump doesnot provide with just users of the single namespace. It infact returns all the users across all namespaces. My command sensuctl --namespace automation dump all -f out.yaml returned all namespaces regardless of the namespace filter while specifically going sensuctl --namespace automation dump checks,handlers,filters,users -f out.yaml still gave users from other namespaces as well. It would be helpful to know after deleting resources in the namespace, what remains to be deleted.

In my case i did find that the following command almost always cleared all the resources in the namespace
sensuctl --namespace automation dump checks,handlers,filters,assets -f out.yaml
sensuctl delete -f out.yaml
senuctl namespace delete automation