in standalone/aws_eks_k8s_client.py [0:0]
def check_pods(session,region,account_id, cluster_name, pod_name_prefix="batch-app") -> dict:
api_client = get_k8s_api_client(session,region,account_id, cluster_name)
v1 = client.CoreV1Api(api_client)
result_dict = {'found_pod':'NO'}
print("get_pods - accessing k8s api through client: " )
try:
print("Listing pods with their IPs:")
ret = v1.list_namespaced_pod(namespace='default')
for pod in ret.items:
if pod.metadata.name.startswith(pod_name_prefix):
result_dict['found_pod'] = 'YES'
print("found pod: %s\t%s\t%s" % (pod.status.pod_ip, pod.metadata.namespace, pod.metadata.name))
break
except ApiException as ex:
print("ApiException:"+ str(ex.reason))
print("ApiException:" + str(ex))
#assign negative points if node termination handler has not be deployed.
except Exception as excp:
result_dict['found_pod'] = 'EXCEPTION'
print("Exception:" + str(excp))
return result_dict