Kubernetes events for container activity on node

3/17/2017

I have Kubernetes cluster with Kubernetes master and nodes. I am interested in listening to the event on Kubernetes master when any node creates/stops container.

Something similar docker events which keeps on listening for the events and pops the output on the screen on some activity.

Can someone please let me know how I can do this for Kubernetes?

-- deepak raykar
kubernetes

1 Answer

3/17/2017

You might want to dive deep into the API docs and check the actual documentation.

In order to see all events, you can watch one of the objects of interests and maybe filter down the list so that you don't see everything. How that's done is described in the API operations guide.

A first super simple try would be: http://<kubernetes-master>:8080/api/v1/pods?watch=true to see the stream of events for the v1.Pod objects.

Another way to discover the API is to use kubectl in verbose mode. So if you found a kubectl command which get's you what you need you could add -v=6 to it to see which API url is called to get the data. In your program you can then use the same URL to get your data without kubectl in the middle.

Using the example from Janos this would be: kubectl get ev -w -v=6 which results in sth like:

...
I0322 17:03:55.738391   18068 round_trippers.go:318] GET http://127.0.0.1:8080/api/v1/watch/namespaces/default/events?resourceVersion=18474970 200 OK in 0 milliseconds
...

Hope any of this helps.

-- pagid
Source: StackOverflow