Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

248
Views
Kubectl wait for service to get external ip

I'm trying to use kubectl to wait for a service to get an external ip assigned. I've been trying to use the below just to get started

kubectl wait --for='jsonpath={.spec.externalTrafficPolicy==Cluster}' --timeout=30s --namespace cloud-endpoints svc/esp-echo

But I keep getting the below error message

error: unrecognized condition: "jsonpath={.spec.externalTrafficPolicy==Cluster}"
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

It is not possible to pass arbitrary jsonpath and there is already a request for the feature.

However, you can use a bash script with some sleep and monitor the service using other kubectl commands:

kubectl get --namespace cloud-endpoints svc/esp-echo --template="{{range .status.loadBalancer.ingress}}{{.ip}}{{end}}"

The above command will return the external IP for the LoadBalancer service for example.

You can write a simple bash file using the above as:

#!/bin/bash
ip=""
while [ -z $ip ]; do
  echo "Waiting for external IP"
  ip=$(kubectl get svc $1 --namespace cloud-endpoints --template="{{range .status.loadBalancer.ingress}}{{.ip}}{{end}}")
  [ -z "$ip" ] && sleep 10
done
echo 'Found external IP: '$ip
over 4 years ago · Santiago Trujillo Report

0

Updated from Krishna Chaurasia's answer, kubectl have implemented the feature to be able to wait on arbitrary jsonpath value now.

However, the catch is the value will only be primitive value, excluding nested primitive value (map[string]interface{} or []interface{})

over 4 years ago · Santiago Trujillo Report

0

You need to provide a condition. Like:

kubectl -n foobar wait --for=condition=complete --timeout=32s foo/bar

Here is a good article that explains that: https://mrkaran.dev/posts/kubectl-wait/

In your case, you might use one of the k8s probes.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!