wpcnjupt
wpcnjupt

Reputation: 31

how to use kubernetes lib to watch all events

guys I want to watch all kubernetes events and I find the source code here: https://github.com/kubernetes/client-go/blob/master/informers/events/v1beta1/event.go

However, I can not find any examples about how to use the functions. Can anyone help me, thanks a lot!

Upvotes: 3

Views: 1754

Answers (2)

apisim
apisim

Reputation: 4586

One or several of these could help:

  • "watches" for (quote) "...efficient change notifications on resources" - see Kubernetes API Concepts as well as the API Reference for a particular version. Example: GET /api/v1/namespaces/test/pods?watch=1&resourceVersion=10245

  • Event Read Operations.

  • kubectl get allows you to specify the -w or --watch flag to start watching updates to a particular object.

I believe the events are for a particular resource or collection of resources, not for all resources.

Upvotes: 1

Daein Park
Daein Park

Reputation: 4693

I’d like to collect the event logs with kubectl or REST API[2] as JSON, then you can send the logs to fluentd for centralized monitoring such as Elasticsearch.

Here is a good sample;[0], though it's OpenShift, but if oc cmd replace with kubectl cmd, it's same with Kubernetes. (Yeah, OpenShift is Enterprise Kubernetes).

[1] is how to implement the fluentd - Elasticsearch stack.

I hope this help you.

Upvotes: 1

Related Questions