Skip to content

Commit 8bdbf6a

Browse files
committed
k8s: add get_pod
1 parent 6c23e2a commit 8bdbf6a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/warnet/k8s.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
import tempfile
55
from pathlib import Path
66
from time import sleep
7+
from typing import Optional
78

89
import yaml
910
from kubernetes import client, config, watch
10-
from kubernetes.client.models import CoreV1Event, V1PodList
11+
from kubernetes.client.models import CoreV1Event, V1Pod, V1PodList
1112
from kubernetes.client.rest import ApiException
1213
from kubernetes.dynamic import DynamicClient
1314
from kubernetes.stream import stream
@@ -41,6 +42,13 @@ def get_pods() -> V1PodList:
4142
return pod_list
4243

4344

45+
def get_pod(name: str, namespace: Optional[str] = None) -> V1Pod:
46+
sclient = get_static_client()
47+
if not namespace:
48+
namespace = get_default_namespace()
49+
return sclient.read_namespaced_pod(name=name, namespace=namespace)
50+
51+
4452
def get_mission(mission: str) -> list[V1PodList]:
4553
pods = get_pods()
4654
crew = []

0 commit comments

Comments
 (0)