diff --git a/CHANGELOG.md b/CHANGELOG.md index a03b6e2..07a4bde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ * `HorizontalPodAutoscaler` * `KubeConfig` learned to handle empty or missing user configuration * `HTTPClient` learned to create an HTTP session with no authentication +* ready supported on all objects if exposed by the kubernetes api ### Bug fixes diff --git a/pykube/objects.py b/pykube/objects.py index 5857578..79ee159 100644 --- a/pykube/objects.py +++ b/pykube/objects.py @@ -95,6 +95,15 @@ def delete(self): if r.status_code != 404: self.api.raise_for_status(r) + @property + def ready(self): + try: + return ( + self.obj["status"]["observedGeneration"] >= self.obj["metadata"]["generation"] + ) + except KeyError as e: + raise NotImplementedError(e) + class NamespacedAPIObject(APIObject): @@ -128,13 +137,6 @@ class Deployment(NamespacedAPIObject, ReplicatedMixin, ScalableMixin): endpoint = "deployments" kind = "Deployment" - @property - def ready(self): - return ( - self.obj["status"]["observedGeneration"] >= self.obj["metadata"]["generation"] and - self.obj["status"]["updatedReplicas"] == self.replicas - ) - class Endpoint(NamespacedAPIObject):