KubernetesWatcher#
- class controller.storage.kubernetes.watcher.KubernetesWatcher(*, method, object_type, kind, name=None, namespace=None, group=None, version=None, plural=None, involved_object=None, resource_version=None, timeout, logger)#
-
Watch Kubernetes for events.
This wrapper around the watch API of the Kubernetes client implements retries and resource version handling and fixes typing problems when used with the Safir
MockKubernetesApi
mock. The latter confuses the type detection in thekubernetes_asyncio
library, which is handled here by passing in an explicit return type.This class is not meant to be used directly by code outside of the Kubernetes storage layer. Use one of the kind-specific watcher classes built on top of it instead.
- Parameters:
method (
Callable
[...
,Awaitable
[Any
]]) – API list method that supports the watch API.object_type (
type
[TypeVar
(T
)]) – Type of object being watched. This cannot be autodiscovered from the method because of the problems with docstring parsing and therefore must be provided by the caller and must match the type of object returned by the method. For custom objects, this should be a dict type.kind (
str
) – Kubernetes kind of object being watched, for error reporting.name (
Optional
[str
], default:None
) – Name of object to watch. Cannot be used withinvolved_object
.namespace (
Optional
[str
], default:None
) – Namespace to watch.group (
Optional
[str
], default:None
) – Group of custom object.version (
Optional
[str
], default:None
) – Version of custom object.plural (
Optional
[str
], default:None
) – Plural of custom object.involved_object (
Optional
[str
], default:None
) – Involved object to watch (used when watching events). Cannot be used withname
.resource_version (
Optional
[str
], default:None
) – Resource version at which to start the watch.timeout (
Optional
[Timeout
]) – Timeout for the watch. This may be None, in which case the watch continues until cancelled or until the iterator is no longer called.logger (
BoundLogger
) – Logger to use.
- Raises:
ValueError – Raised if
name
andinvolved_object
are both specified.