<p>I have a piece of code to run on a k8s cluster. I need shutdown those k8s nodes when all of my code running in the pods get finished. I let my code to serve on a port until the job of the code doing completed, and I will keep the program running to avoid the replication controller starting another pod. and I defined a service in k8s to routing the request. 
Externally, I wrote a script to ping the service until the service can't response with code 200, then I will shutdown those k8s nodes to save resource.
My question is when my code in the pod no longer to serve the port, will k8s service still route the incoming request to that pod or not.
And, is there any other way to achieve the equivalent result?   </p>

<p>If a TCP connection can't be opened to the pod's IP on the given port, a different pod will be connected to instead.</p>

<p>In other words, as long as the pod closes the socket that was listening on the port, no requests should be sent to it after that point.</p>
