This project has been started as a need to monitor one of my kubernetes
cluster, and notably the Job
s failures, but can be used to monitor any kind of core/v1:Event
in the cluster.
The project configuration is loaded from a .yaml
file, the path can be provided using the KUBEVENTSD_CONFIG_PATH
environment variable.
The configuration is separated into two parts:
This defines filters on the events and to which senders
the event should be sent if there is a match.
reason
(list[str]): A list of reasons that must match thecore/v1:Event
to be forwarded.type
(list[str]): A list of types that must match thecore/v1:Event
to be forwarded.namespace
(list[str]): A list of namespaces that must match the involved object to be forwarded.kind
(list[str]): A list of kinds that must match the involved object to be forwarded.
When a field is ommited, it's considered to be a wildcard match.
events:
# This forwards all events.
- to: [sender0]
# This forwards all events with 'Started' or 'Completed' as a `reason`.
- reason: [Started, Completed]
to: [sender1]
# This forward all events with 'Killed' or 'BackoffLimitExceeded' as a `reason` in the 'default' `namespace`.
- reason: [Killed, BackoffLimitExceeded]
namespace: [default]
to: [sender2]
This defines the targets to which the event could be sent.
senders:
- name: sender0
spec:
kind: Webhook
url: https://hook.example.com
- name: sender1
spec:
kind: Matrix
template: |
{% comment %}
This contains a liquid-rs template to format the event before sending
{% endcomment %}
homeserverUrl: https://matrix.org
userId: "@example:matrix.org"
passwordEnv: MATRIX_PASSWORD
roomId: "!***:matrix.org"
This sender will POST
the entire kubernetes core/v1:Event
object as a JSON body to the provided URL.
url
(URL): The URL of the webhook.
This sender will send the core/v1:Event
as a templatized message to the specified Matrix room using the provided credentials.
template
(liquid template): The template for the message rendering, with allcore/v1:Event
accessibles.homeserverUrl
(URL): The URL of the Matrix server that is the homeserver of the the provided user.userId
(Matrix UserId): The user's identifier to log in the homeserver.passwordEnv
(str): The name of the environment variable that contains the password.roomId
(Matrix RoomId): The identifier of the room on which the message should be sent.