in kubernetes, will service route the request to pod no longer serve the port but alive

5/29/2015

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?

-- Zhong Liu
kubernetes
service

1 Answer

5/29/2015

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.

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.

-- Alex Robinson
Source: StackOverflow