Exemplo n.º 1
0
 def deployments(self) -> Sequence[api.Deployment]:
     return [
         deployment_from_client(
             raw_deployment,
             self._controller_to_pods[raw_deployment.metadata.uid])
         for raw_deployment in self._external_api.raw_deployments
     ]
Exemplo n.º 2
0
    def deployments(self) -> Sequence[api.Deployment]:
        result = []
        for raw_deployment in self.apps_api.deployments():
            selector = raw_deployment.spec.selector
            label_selector = (
                ",".join([f"{key}={value}" for key, value in selector.match_labels.items()])
                if selector.match_labels is not None
                else ""
            )

            # TODO for pod_uids computation: Needs an integration test
            # TODO for pod_uids computation: Efficiency is questionable at best here. What we want
            # is, that each object kind (Deployment, DaemonSet, ReplicaSet,...) can map to it's
            # respective pods. For this need to parse the object_references of all the pods once.
            # But we should not need to parse them more than once (here we parse the object
            # references multiple times, if two deployments differ only by a match_expression
            # selector. Moreover, it probably makes sense to only call
            # self.core_api.query_namespaced_pods with no restriction).
            # When we do this refactoring, we should also consider writing owned_by_deployment as a
            # free function.
            result.append(
                deployment_from_client(
                    raw_deployment,
                    pod_uids=[
                        pod.metadata.uid
                        for pod in self.core_api.query_namespaced_pods(
                            raw_deployment.metadata.namespace, label_selector
                        )
                        if self.apps_api.owned_by_deployment(pod, raw_deployment.metadata.uid)
                    ],
                )
            )
        return result
Exemplo n.º 3
0
 def deployments(self) -> Sequence[api.Deployment]:
     result = []
     for raw_deployment in self.apps_api.deployments():
         selector = raw_deployment.spec.selector
         label_selector = ",".join(
             [f"{key}={value}" for key, value in selector.match_labels.items()]
         )
         result.append(
             deployment_from_client(
                 raw_deployment,
                 pod_uids=[
                     pod.metadata.uid
                     for pod in self.core_api.query_namespaced_pods(
                         raw_deployment.metadata.namespace, label_selector
                     )
                 ],
             )
         )
     return result