'Get Ingress gateway IP address using Kubernetes Python client

I am using the following kubectl command to get the Ingress host IP address after my Seldon Deployment is avaible.

kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}'

I would like to run the same command from the Kubernetes Python API but cannot find any information in the documentation on how to do so.

Could you please help me out?

Thanks in advance.



Solution 1:[1]

import kubernetes

network_api =kubernetes.client.NetworkingV1Api()
service = network_api.read_namespaced_ingress(ingress_name, namespace)
print(service.status.load_balancer.ingress[0].ip)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vitaliy Novakivskiy