bianchi
bianchi

Reputation: 500

Kubernetes go client: list events

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)

Upvotes: 0

Views: 1748

Answers (1)

Abu Hanifa
Abu Hanifa

Reputation: 3047

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.

Upvotes: 1

Related Questions