I am trying to find a way to determine the status of the "kubectl port-forward" command. There is a way to determine the readiness of a pod, a node...: i.e. "kubectl get pods" etc...
Is there a way to determine if the kubectl port-forward command has completed and ready to work?
Thank you.
Answering directly to your question - no, you can not determine the status of kubectl port-forward
command. The only way of determining what is going on in the background is to inspect the output of this command. The output will be something like:
Forwarding from 127.0.0.1:6379 -> 6379
Forwarding from [::1]:6379 -> 6379
I may suggest using service type NodePort instead of port-forward
. Using the NodePort
, you are able to expose your app as a service and have access from outside the Kubernetes. For more examples use this url.
I have the same understanding as you @VKR.
The way that I choose to solve this was to have a loop with a curl every second to check the status of the forwarded port. It works but I had hoped for a prebaked solution to this.
do curl:6379
timer=0
while curl is false and timer <100
timer++
curl:6379
sleep 1
Thank you @Nicola and @David, I will keep those in mind when I get past development testing.