How to verify kubernetes service load balancer init (call-back not polling)

2/16/2018

I have a multi-service kubernetes deployment on GKE. My services are load balancers which take some time to init. During initiation time the services ingress URL's are pending.
Is there a way to wait for an init callback, which isn't:

  1. polling the service.
  2. parsing the specific field.
  3. making sure it's an ip and not Pending.

My app deployment uses urls to dynamically allocate API URLs to clients (source urls for html). and I would like to have this feature for any deployment regardless of domain name.

P.S

My current hack is:

  1. Wait a while.
  2. Kill the pods letting the deployments and statefullsets start new pods.
  3. Use init scripts with python kubernetes parsers to get the service ingress IP.
outer_ip = svc.status.load_balancer.ingress[0].ip

Suggestion: A callback of the style onReady(Service){}, chould specify a status API e.g. an error or a pending status rather than something which may change with implementation.

-- Rubber Duck
google-cloud-platform
google-kubernetes-engine
kubectl
kubernetes

0 Answers