Skip to content

Commit

Permalink
Update method of determining the deployment in which a pod belongs
Browse files Browse the repository at this point in the history
  • Loading branch information
jaclark5 committed Feb 10, 2025
1 parent 20a1f9e commit a133c4a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion kubecustom/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def utilization_per_deployment(keep_key="", namespace=None, verbose=True):
" CPU Ut%, CPU Req"
)
print(
"_____________________________________________________________________________"
"_____________________________________________________________________________________________________"
)
for dep_name, pod_info in dep_pod_info.items():
try:
Expand Down
7 changes: 5 additions & 2 deletions kubecustom/pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def get_pod_list(deployment_name=None, namespace=None):
pod
for pod in pods.items
if all(
owner.kind == "ReplicaSet" and owner.name.startswith(deployment_name)
owner.kind == "ReplicaSet"
and "-".join(owner.name.split("-")[:-1]) == deployment_name
for owner in pod.metadata.owner_references
)
]
Expand Down Expand Up @@ -141,7 +142,9 @@ def sort_pods_by_deployment(pods, deployment_names, keep_key=""):
if keep_key not in dep_name:
continue
pods_sorted[dep_name] = {
pod_name: value for pod_name, value in pods.items() if dep_name in pod_name
pod_name: value
for pod_name, value in pods.items()
if "-".join(pod_name.split("-")[:-2]) == dep_name
}

return pods_sorted
Expand Down

0 comments on commit a133c4a

Please sign in to comment.