Commit 4664a56d authored by Santhosh Kumar's avatar Santhosh Kumar

cleanup code

parent 50e05a1a
......@@ -502,20 +502,55 @@ def describe_pods_events(deployment_name, namespace="default"):
except Exception as e:
print("Error describing pods and events:", e)
def get_hpa1():
deployment_name = input("Enter the deployment name to delete: ")
namespace="default"
try:
# Get HPA
hpa = scale_api.read_namespaced_horizontal_pod_autoscaler(name=deployment_name+"-hpa", namespace=namespace)
print("Name: %s, Min replicas: %d, Max replicas: %d" % (hpa.metadata.name, hpa.spec.min_replicas, hpa.spec.max_replicas))
for metric in hpa.spec.metrics:
if metric.type == "Resource":
print("Resource metric: %s, Target average utilization: %d%%" % (metric.resource.name, metric.resource.target.average_utilization))
# Add handling for other metric types if needed
except Exception as e:
print("Exception when describing HPA: %s" % str(e))
def get_hpa():
deployment_name = input("Enter the deployment name to delete: ")
namespace="default"
label_selector = f"involvedObject.name={deployment_name}-hpa"
try:
# Get events related to the HPA
events = core_api.list_namespaced_event(namespace=namespace, label_selector=label_selector)
# Print events
for event in events.items:
print(f"Name: {event.metadata.name}")
print(f"Message: {event.message}")
print(f"Reason: {event.reason}")
print(f"Last Timestamp: {event.last_timestamp}")
print("----")
except Exception as e:
print("Exception when listing events: %s" % str(e))
def select_misc_operation():
print("Select the miscellaneous operation:")
print("1. Get Cluster IP")
print("2. Show Additional Pods Information")
print("3. Exit")
print("3. Show HPA info ")
print("4. Exit")
while True:
try:
choice = int(input("Enter your choice (1-3): "))
if 1 <= choice <= 3:
choice = int(input("Enter your choice (1-4): "))
if 1 <= choice <= 4:
return choice
else:
print(choice)
print("Invalid choice. Please enter a number between 1 and 3.")
print("Invalid choice. Please enter a number between 1 and 4.")
except ValueError:
print("Invalid input. Please enter a number.")
......@@ -536,6 +571,9 @@ def misc_info():
# Call function to deploy function
describe_pods_events(function_name, namespace)
elif choice == 3:
print("HPA informatio...")
get_hpa()
elif choice == 4:
print("Exiting...")
break
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment