Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

250
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda