Skip to content

Commit 89d1b9f

Browse files
feat: add support for StrimziPodSet (#388)
fixes #372 --------- Signed-off-by: Saketh kappala <[email protected]> Co-authored-by: Avi-Robusta <[email protected]>
1 parent 95550e0 commit 89d1b9f

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

robusta_krr/core/integrations/kubernetes/__init__.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ async def list_scannable_objects(self) -> list[K8sObjectData]:
101101
workload_object_lists = await asyncio.gather(
102102
self._list_deployments(),
103103
self._list_rollouts(),
104+
self._list_strimzipodsets(),
104105
self._list_deploymentconfig(),
105106
self._list_all_statefulsets(),
106107
self._list_all_daemon_set(),
@@ -204,7 +205,10 @@ def __build_scannable_object(
204205
labels = {}
205206
annotations = {}
206207
if item.metadata.labels:
207-
labels = item.metadata.labels
208+
if type(item.metadata.labels) is ObjectLikeDict:
209+
labels = item.metadata.labels.__dict__
210+
else:
211+
labels = item.metadata.labels
208212

209213
if item.metadata.annotations:
210214
if type(item.metadata.annotations) is ObjectLikeDict:
@@ -299,7 +303,7 @@ async def _list_scannable_objects(
299303

300304
result.extend(self.__build_scannable_object(item, container, kind) for container in containers)
301305
except ApiException as e:
302-
if kind in ("Rollout", "DeploymentConfig") and e.status in [400, 401, 403, 404]:
306+
if kind in ("Rollout", "DeploymentConfig", "StrimziPodSet") and e.status in [400, 401, 403, 404]:
303307
if self.__kind_available[kind]:
304308
logger.debug(f"{kind} API not available in {self.cluster}")
305309
self.__kind_available[kind] = False
@@ -364,6 +368,30 @@ async def _extract_containers(item: Any) -> list[V1Container]:
364368
extract_containers=_extract_containers,
365369
)
366370

371+
def _list_strimzipodsets(self) -> list[K8sObjectData]:
372+
# NOTE: Using custom objects API returns dicts, but all other APIs return objects
373+
# We need to handle this difference using a small wrapper
374+
return self._list_scannable_objects(
375+
kind="StrimziPodSet",
376+
all_namespaces_request=lambda **kwargs: ObjectLikeDict(
377+
self.custom_objects.list_cluster_custom_object(
378+
group="core.strimzi.io",
379+
version="v1beta2",
380+
plural="strimzipodsets",
381+
**kwargs,
382+
)
383+
),
384+
namespaced_request=lambda **kwargs: ObjectLikeDict(
385+
self.custom_objects.list_namespaced_custom_object(
386+
group="core.strimzi.io",
387+
version="v1beta2",
388+
plural="strimzipodsets",
389+
**kwargs,
390+
)
391+
),
392+
extract_containers=lambda item: item.spec.pods[0].spec.containers,
393+
)
394+
367395
def _list_deploymentconfig(self) -> list[K8sObjectData]:
368396
# NOTE: Using custom objects API returns dicts, but all other APIs return objects
369397
# We need to handle this difference using a small wrapper

robusta_krr/core/models/objects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from robusta_krr.utils.batched import batched
99
from kubernetes.client.models import V1LabelSelector
1010

11-
KindLiteral = Literal["Deployment", "DaemonSet", "StatefulSet", "Job", "CronJob", "Rollout", "DeploymentConfig"]
11+
KindLiteral = Literal["Deployment", "DaemonSet", "StatefulSet", "Job", "CronJob", "Rollout", "DeploymentConfig", "StrimziPodSet"]
1212

1313

1414
class PodData(pd.BaseModel):

robusta_krr/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def run_strategy(
9898
None,
9999
"--resource",
100100
"-r",
101-
help="List of resources to run on (Deployment, StatefulSet, DaemonSet, Job, Rollout). By default, will run on all resources. Case insensitive.",
101+
help="List of resources to run on (Deployment, StatefulSet, DaemonSet, Job, Rollout, StrimziPodSet). By default, will run on all resources. Case insensitive.",
102102
rich_help_panel="Kubernetes Settings",
103103
),
104104
selector: Optional[str] = typer.Option(

0 commit comments

Comments
 (0)