2

Okay, the title is quite mouthful. But it's actually describing the situation.

I deployed a service on GKE in namespace argo-events. Something was wrong with it so I tore it down:

kubectl delete namespace argo-events

Actually, that's already where the problems started (I suspect a connection to the problem described below) and I had to resort to a hack because argo-events got stuck in a Terminating state forever. But the result was as desired - namespace seemed to be gone together with all objects in it.

Because of problems with redeployment I inspected the GKE Object Browser (just looking around - cannot filter for argo-events namespace anymore as it is officially gone) where I stumbled upon two lingering objects in ns argo-events:

enter image description here

argo-events is not listed by kubectl get namespaces. Just confirming that.

And I can find those two objects if I look them up specifically:

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

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

But - I cannot find anything by asking for all objects:

$ kubectl get all -n argo-events
No resources found in argo-events namespace.

So my question is. How can I generically list all lingering objects in argo-events?

I'm asking because otherwise I'd have to inspect the entire Object Browser Tree to maybe find more objects (as I cannot select the namespace anymore).

Raffael
  • 19,547
  • 15
  • 82
  • 160

1 Answers1

1

By using command $ kubectl get all you will only print a few resources like:

  • pod
  • service
  • daemonset
  • deployment
  • replicaset
  • statefulset
  • job
  • cronjobs

It won't print all resources which can be found when you will use $ kubectl api-resources.

Example

When create PV from PersistentVolume documentation it won't be listed in $ kubectl get all output, but it will be listed if you will specify this resource.

$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/pods/storage/pv-volume.yaml
persistentvolume/task-pv-volume created
$ kubectl get pv
NAME             CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM   STORAGECLASS   REASON   AGE
task-pv-volume   10Gi       RWO            Retain           Available           manual                  3m12s
$ kubectl get all
NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
service/kubernetes   ClusterIP   10.3.240.1   <none>        443/TCP   86m
$ 

If you would like to list all resources from specific namespace you should use command below:

kubectl -n argo-events api-resources --namespaced=true -o name | xargs --verbose -I {} kubectl -n argo-events get {} --show-kind --ignore-not-found

Above solution was presented in Github thread kubectl get all does not list all resources in a namespace. In this thread you might find some additional variations of above command.

In addition, you can also check How to List all Resources in a Kubernetes Namespace article. You can find there method to list resources using function.

edbighead
  • 5,607
  • 5
  • 29
  • 35
PjoterS
  • 12,841
  • 1
  • 22
  • 54