简体   繁体   English

在kubernetes中,将服务路由到Pod的请求不再服务于该端口但仍然有效

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

I have a piece of code to run on a k8s cluster. 我有一段代码可以在k8s集群上运行。 I need shutdown those k8s nodes when all of my code running in the pods get finished. 当我在Pod中运行的所有代码完成时,我需要关闭那些k8s节点。 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. 我让我的代码在端口上运行,直到完成代码工作为止,并且我将保持程序运行,以避免复制控制器启动另一个Pod。 and I defined a service in k8s to routing the request. 我在k8s中定义了一项服务来路由请求。 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. 在外部,我编写了一个脚本来ping服务,直到该服务无法用代码200响应为止,然后我将关闭这些k8s节点以节省资源。 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. 我的问题是,当我在pod中的代码不再服务于该端口时,k8s服务是否仍会将传入的请求路由到该pod。 And, is there any other way to achieve the equivalent result? 而且,还有其他方法可以达到同等效果吗?

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. 如果无法在给定端口上打开到Pod IP的TCP连接,则会连接到另一个Pod。

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. 换句话说,只要Pod关闭了正在侦听该端口的套接字,那之后就不应再向其发送任何请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM