Kubernetes go client: list events

12/5/2018

I am trying to get a list of events in the namespace, but with or without FieldSelector I get an empty list. Is this the right way to do it?

            eventListOptions := metav1.ListOptions{FieldSelector: fields.OneTermEqualSelector("involvedObject.name", job.Name).String()}
            jobEvents, _ := clientset.EventsV1beta1().Events(GetNamespace()).List(eventListOptions)
-- bianchi
go
kubernetes

1 Answer

12/6/2018

If you print error return by List, you should get error something like "involvedObject.name" is not a known field selector: only "metadata.name", "metadata.namespace"

use CoreV1 instead of EventsV1beta1

The line will be something like below:

jobEvents, _ := clientset.CoreV1().Events(GetNamespace()).List(eventListOptions)


"involvedObject.name", job.Name isn't supported by EventsV1beta1

Hope it'll help.

-- Abu Hanifa
Source: StackOverflow