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 @@ -178,7 +178,7 @@ def delete_pod(pod_name, namespace):
178
178
179
179
# Delete remaining pods
180
180
pods = get_pods ()
181
- for pod in pods . items :
181
+ for pod in pods :
182
182
futures .append (executor .submit (delete_pod , pod .metadata .name , pod .metadata .namespace ))
183
183
184
184
# Wait for all tasks to complete and print results
@@ -346,7 +346,7 @@ def _logs(pod_name: str, follow: bool):
346
346
if pod_name == "" :
347
347
try :
348
348
pods = get_pods ()
349
- pod_list = [item .metadata .name for item in pods . items ]
349
+ pod_list = [item .metadata .name for item in pods ]
350
350
except Exception as e :
351
351
print (f"Could not fetch any pods in namespace { namespace } : { e } " )
352
352
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