Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get Events associated with a Pod via the API?

Tags:

kubernetes

When I do a kubectl describe <pod>, the bottom section has an "Events" section, displaying Events related to that pod. For example, an event with Reason "failedScheduling", with the message "Failed for reason PodFitsResources and possibly others"

How can I query the API to return that list of events?

If I call /api/v1/namespaces/<ns>/pods/<pod_name>, it doesn't return any Events. If I try the /api/v1/events endpoint, I can specify a labelSelector parameter, but the name of the pod isn't a label of the Event, though it is in the object.involvedObject.name field.

I could request the entire Event stream and filter out the few Events that interest me client-side, but that seems like overkill. kubectl is able to do it, so I figure there must be some way that I'm missing.

Thanks.

like image 483
JonM Avatar asked Oct 01 '15 18:10

JonM


1 Answers

I think events support a fieldSelector for the involved object kind and name

You can also turn the verbosity level on kubectl up to 8 to see network traces to see what it is doing

like image 58
Jordan Liggitt Avatar answered Oct 09 '22 12:10

Jordan Liggitt