graph LR
WatchComponent["WatchComponent"]
ApiClientComponent["ApiClientComponent"]
CoreV1ApiComponent["CoreV1ApiComponent"]
DynamicClientComponent["DynamicClientComponent"]
E2ETestComponent["E2ETestComponent"]
DynamicClientComponent -- "uses for watch operations" --> WatchComponent
WatchComponent -- "relies on for deserialization and API communication" --> ApiClientComponent
CoreV1ApiComponent -- "uses for API operations" --> ApiClientComponent
E2ETestComponent -- "initializes" --> ApiClientComponent
E2ETestComponent -- "uses for resource management" --> CoreV1ApiComponent
E2ETestComponent -- "uses to test watch functionality" --> WatchComponent
The Watcher subsystem in the Kubernetes client library is designed to provide real-time monitoring of Kubernetes resources. Its primary purpose is to enable applications to react to changes (creation, updates, deletions) in the cluster without continuous polling. The core flow involves a Watcher component establishing a stream with the Kubernetes API, which then receives event notifications. These raw event data are deserialized into usable Python objects by an API client, allowing applications to process and respond to the changes. End-to-end tests validate this real-time monitoring capability by simulating resource changes and verifying the received events.
The WatchComponent is responsible for establishing and maintaining a stream of events from the Kubernetes API. It handles the deserialization of incoming event data into Python objects, manages the lifecycle of the watch operation, and implements retry mechanisms for expired watch requests.
Related Classes/Methods:
kubernetes.base.watch.watch.Watch(86:223)kubernetes.base.watch.watch._find_return_type(47:51)kubernetes.base.watch.watch.SimpleNamespace(41:44)kubernetes.base.watch.watch.iter_resp_lines(54:83)
The ApiClientComponent provides fundamental functionalities for interacting with the Kubernetes API. Its primary role in this subsystem is to deserialize raw API responses into structured Python objects, which is crucial for the WatchComponent to process event data, and to make HTTP requests.
Related Classes/Methods:
The CoreV1ApiComponent offers a programmatic interface to the Kubernetes Core V1 API. It includes methods for managing core resources such as ConfigMaps, enabling operations like creation, listing, patching, and deletion, which are utilized in testing scenarios.
Related Classes/Methods:
The DynamicClientComponent provides a flexible and dynamic way to interact with Kubernetes resources without requiring pre-generated client models. It can initiate watch operations on various resources by leveraging the WatchComponent.
Related Classes/Methods:
The E2ETestComponent encompasses end-to-end tests specifically designed to validate the watch functionality within the Kubernetes client library. It demonstrates the practical application of the WatchComponent in conjunction with the CoreV1ApiComponent to monitor changes in Kubernetes resources like ConfigMaps.
Related Classes/Methods: