def find_pods(self, namespace, selector=None, deployment_name=None):
        """ Find pods in a namespace, for a deployment or selector.
        """
        pods = []
        for ns in self.preprocess_namespace(namespace):
            try:
                for pod in self.k8s_client.list_pods(
                    namespace=ns,
                    selector=selector,
                    deployment_name=deployment_name,
                ):
                    pods.append(pod)
            except Exception as e:
                self.logger.exception(e)
        pod_objects = []
        if pods is not None:
            for i, item in enumerate(pods):
                        container_ids = []
                        restart_count = []
                        if item.status.container_statuses:
                            for status in item.status.container_statuses:
                                container_ids.append(status.container_id)
                                restart_count.append(status.restart_count)

                        pod_objects.append(Pod(
                            num=i,
                            name=item.metadata.name,
                            namespace=item.metadata.namespace,
                            uid=item.metadata.uid,
                            host_ip=item.status.host_ip,
                            ip=item.status.pod_ip,
                            container_ids=container_ids,
                            restart_count=sum(restart_count),
                            state=get_status(item.status),
                            labels=item.metadata.labels,
                            annotations=item.metadata.annotations,
                            meta=item,
                        ))
        self.last_pods = pod_objects
        return pod_objects
 Find pods in a namespace, for a deployment or selector.
        
powerfulseal/k8s/k8s_inventory.py