File tree Expand file tree Collapse file tree 2 files changed +20
-14
lines changed Expand file tree Collapse file tree 2 files changed +20
-14
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ def delete_pod(pod_name, namespace):
138
138
139
139
# Delete remaining pods
140
140
pods = get_pods ()
141
- for pod in pods . items :
141
+ for pod in pods :
142
142
futures .append (executor .submit (delete_pod , pod .metadata .name , pod .metadata .namespace ))
143
143
144
144
# Wait for all tasks to complete and print results
@@ -306,7 +306,7 @@ def _logs(pod_name: str, follow: bool):
306
306
if pod_name == "" :
307
307
try :
308
308
pods = get_pods ()
309
- pod_list = [item .metadata .name for item in pods . items ]
309
+ pod_list = [item .metadata .name for item in pods ]
310
310
except Exception as e :
311
311
print (f"Could not fetch any pods in namespace { namespace } : { e } " )
312
312
return
Original file line number Diff line number Diff line change 9
9
from kubernetes import client , config , watch
10
10
from kubernetes .client import CoreV1Api
11
11
from kubernetes .client .exceptions import ApiException
12
- from kubernetes .client .models import V1Namespace , V1PodList
12
+ from kubernetes .client .models import V1Namespace , V1Pod , V1PodList
13
13
from kubernetes .dynamic import DynamicClient
14
14
from kubernetes .stream import stream
15
15
@@ -34,19 +34,25 @@ def get_dynamic_client() -> DynamicClient:
34
34
return DynamicClient (client .ApiClient ())
35
35
36
36
37
- def get_pods () -> V1PodList :
37
+ def get_pods () -> list [ V1Pod ] :
38
38
sclient = get_static_client ()
39
- try :
40
- pod_list : V1PodList = sclient .list_namespaced_pod (get_default_namespace ())
41
- except Exception as e :
42
- raise e
43
- return pod_list
44
-
45
-
46
- def get_mission (mission : str ) -> list [V1PodList ]:
39
+ pods : list [V1Pod ] = []
40
+ namespaces = get_namespaces ()
41
+ for ns in namespaces :
42
+ namespace = ns .metadata .name
43
+ try :
44
+ pod_list : V1PodList = sclient .list_namespaced_pod (namespace )
45
+ for pod in pod_list .items :
46
+ pods .append (pod )
47
+ except Exception as e :
48
+ raise e
49
+ return pods
50
+
51
+
52
+ def get_mission (mission : str ) -> list [V1Pod ]:
47
53
pods = get_pods ()
48
- crew = []
49
- for pod in pods . items :
54
+ crew : list [ V1Pod ] = []
55
+ for pod in pods :
50
56
if "mission" in pod .metadata .labels and pod .metadata .labels ["mission" ] == mission :
51
57
crew .append (pod )
52
58
return crew
You can’t perform that action at this time.
0 commit comments