Just to add answers here, the best option now is to use a bash script. For convenience, I put it on one line, which includes the export of the environment variable.
Team wait and find the Kubernetes service endpoint
bash -c 'external_ip=""; while [ -z $external_ip ]; do echo "Waiting for end point..."; external_ip=$(kubectl get svc NAME_OF_YOUR_SERVICE --template="{{range .status.loadBalancer.ingress}}{{.ip}}{{end}}"); [ -z "$external_ip" ] && sleep 10; done; echo "End point ready-" && echo $external_ip; export endpoint=$external_ip'
I also changed your script so that it only waits if ip is not available. The last bit exports an environment variable named "endpoint"
Bash script to test this service
Save this as check-endpoint.sh and then you can run $sh check-endpoint.sh SERVICE_NAME
#!/bin/bash # Pass the name of a service to check ie: sh check-endpoint.sh staging-voting-app-vote # Will run forever... external_ip="" while [ -z $external_ip ]; do echo "Waiting for end point..." external_ip=$(kubectl get svc $1 --template="{{range .status.loadBalancer.ingress}}{{.ip}}{{end}}") [ -z "$external_ip" ] && sleep 10 done echo 'End point ready:' && echo $external_ip
Using this in the Codefresh Step
I use this for the Codefresh pipeline, and when it does, it passes the $ endpoint variable.
GrabEndPoint: title: Waiting for endpoint to be ready image: codefresh/plugin-helm:2.8.0 commands: - bash -c 'external_ip=""; while [ -z $external_ip ]; do echo "Waiting for end point..."; external_ip=$(kubectl get svc staging-voting-app-vote --template="{{range .status.loadBalancer.ingress}}{{.ip}}{{end}}"); [ -z "$external_ip" ] && sleep 10; done; echo "End point ready-" && echo $external_ip; cf_export endpoint=$external_ip'
source share