File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 44
55[ Unreleased ] : https://github.com/chaostoolkit/chaostoolkit-kubernetes/compare/0.31.1...HEAD
66
7+ ### Added
8+
9+ * A new probe to list cluster events
10+
711## [ 0.31.1] [ ] - 2023-10-02
812
913[ 0.31.1 ] : https://github.com/chaostoolkit/chaostoolkit-kubernetes/compare/0.31.0...0.31.1
Original file line number Diff line number Diff line change 1+ import json
2+ from typing import Any , Dict
3+
4+ from chaoslib .types import Configuration , Secrets
5+ from kubernetes import client
6+
7+ from chaosk8s import create_k8s_api_client
8+
9+ __all__ = ["get_events" ]
10+
11+
12+ def get_events (
13+ label_selector : str = None ,
14+ limit : int = 100 ,
15+ configuration : Configuration = None ,
16+ secrets : Secrets = None ,
17+ ) -> Dict [str , Any ]:
18+ """
19+ Retrieve Kubernetes events across all namespaces. If a `label_selector`
20+ is set, filter to that selector only.
21+ """
22+ api = create_k8s_api_client (secrets )
23+
24+ v1 = client .EventsV1Api (api )
25+ ret = v1 .list_event_for_all_namespaces (
26+ _preload_content = False , label_selector = label_selector , limit = limit
27+ )
28+
29+ return json .loads (ret .read ().decode ("utf-8" ))
You can’t perform that action at this time.
0 commit comments