Is there a way to configure Kubernetes (or kubectl) so that an attempt to delete a namespace that has Kubernetes resources will result in an error?
Here is an example:
$ kubectl create ns testing
namespace/testing created
$ kubectl apply -n testing -f pod-nginx.yaml
pod/example-pod created
$ kubectl get -n testing pods
NAME READY STATUS RESTARTS AGE
example-pod 1/1 Running 0 5s
$ kubectl delete ns testing
namespace "testing" deleted
$ kubectl get -n testing pods
No resources found in testing namespace.
What I want is for the delete command (kubectl delete ns testing) to not delete anything, but rather to return with an error of the form "cannot delete namespace because it contains resources".
Is this possible?