How to force delete resources in a non-existant namespace?

3/3/2021

This question is a follow up of: https://stackoverflow.com/q/66453781/562440

Long story short:

$ kubectl get namespaces
NAME              STATUS   AGE
argo              Active   27d
default           Active   27d
kube-node-lease   Active   27d
kube-public       Active   27d
kube-system       Active   27d

$ kubectl get eventbus -n argo-events
NAME      AGE
default   17h

$ kubectl get eventsource -n argo-events
NAME                  AGE
pubsub-event-source   14h

There are two resources in namespace argo-events which actually no longer exits because I deleted it and expected it to be gone with all resources in it. Obviously something didn't work as expected.

Now (after listing potentially more objects - first question) I want to really get rid of those resources because they seem to block a redeployment.

But this ...

$ kubectl delete eventbus default -n argo-events
eventbus.argoproj.io "default" deleted
^C
$ kubectl delete eventsource pubsub-event-source -n argo-events
eventsource.argoproj.io "pubsub-event-source" deleted
^C

... doesn't work.

So, how do I force their deletion?


UPDATE:

$ kubectl describe eventbus default -n argo-events | grep -A 3 final
        f:finalizers:
          .:
          v:"eventbus-controller":
      f:status:
$ kubectl describe eventsource pubsub-event-source -n argo-events | grep -A 3 final
        f:finalizers:
          .:
          v:"eventsource-controller":
      f:spec:
-- Raffael
google-kubernetes-engine
kubernetes

2 Answers

3/3/2021

What about:

kubectl delete eventsource pubsub-event-source -n argo-events --grace-period=0 --force

?

-- Paul Chibulcuteanu
Source: StackOverflow

3/3/2021

This worked:

$ kubectl create namespace argo-events
namespace/argo-events created

$ kubectl patch eventsource/pubsub-event-source -p '{"metadata":{"finalizers":[]}}' --type=merge -n argo-events
eventsource.argoproj.io/pubsub-event-source patched

$ kubectl patch eventbus/default -p '{"metadata":{"finalizers":[]}}' --type=merge -n argo-events
eventbus.argoproj.io/default patched

$ kubectl delete namespace argo-events
namespace "argo-events" deleted

If somebody stumbles upon this answer and knows why this works - please add an explanation in a comment. That would be cool, thanks.

-- Raffael
Source: StackOverflow