简体   繁体   中英

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.

There's a separate client function for each REST operation on each Kubernetes object type. Once you have that object, you can navigate it like any other Python object.

service = kubernetes.client.read_namespaced_service('istio-ingressgateway', 'istio-system')
print(service.status.load_balancer.ingress[0].ip)
# Note the capitalization ^^^^ of load_balancer, not loadBalancer

The service object is a V1Service object. More generally, the API documentation includes every method call and documentation for all of the request and return types.

A Service is a standard Kubernetes object. If you were dealing with some of the Istio-specific objects like VirtualServices, there is a separate API for custom resources .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM