当Pod处于“忙碌"状态时,指定给Kubernetes. [英] Specify to Kubernetes when a Pod is "busy"

查看:67
本文介绍了当Pod处于“忙碌"状态时,指定给Kubernetes.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个微服务正在Kubernetes上运行.我想在Pod忙时指定K8s负载均衡器,因为我当前无法正常运行.

One of my micro service is running on Kubernetes. I would like to specify to K8s load balancer when a pod is busy because the behaviour that I get currently is not ok.

一个例子:

我有8个Pod正在运行,每个Pod一次可以处理1个请求.每个请求占用分配给Pod的CPU内核的70%到100%.但是,当我向应用程序发送8个请求时,Kubernetes不会将这些请求分派到8个Pod,而是尝试仅使用一个.而且由于我(通过线程池)阻塞了每个应用程序副本,一次只能使用一个线程,所以请求的请求当然会排队到pod 1.

I have 8 pods running, each pod can process 1 request at a time. Each request take from 70 to 100% of the CPU core allocated to the pod. But when I send 8 requests to my application, Kubernetes does not dispatch those requests to the 8 pods but try to use only one. And since I'm blocking (via threadpool) each replica of app to use only one thread at a time, of course requests are queued for pod 1.

所以我的问题是:我如何告诉Kubernetes POD 1忙,并且负载均衡器必须将请求2分发到POD 2?

So my question is: How can I tell Kubernetes that POD 1 is busy and that load-balancer must dispatch request 2 to POD 2 ?

注意:出于开发和测试目的,我在Windows 10和kubectl上使用Docker桌面(适用于Windows的Docker).

Note: For dev and test purpose I'm using Docker Desktop (Docker for Windows) on Windows 10 and kubectl.

推荐答案

正如普罗米修斯建议的那样,您可以使用活动度探针,并且我建议将 rediness探针一起添加.

As prometherion suggested you can use the liveness probe and also i would suggest to add the rediness probe together.

您可以查看官方文档:

you can have a look at the official document : https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/

有时,应用程序暂时无法提供流量.例如,启动时,应用程序首先需要加载大数据或配置文件.

Sometimes, applications are temporarily unable to serve traffic. For example when, application first need to load large data or configuration files during startup.

在这种情况下,您不想杀死该应用程序,但也不想将其中的流量发送到Pod.K8s提供了准备就绪探针以检测和缓解这些情况.装有容器的容器报告其尚未准备就绪,无法通过Kubernetes Services接收流量.

In such cases, you don’t want to kill the application, but you don’t want to send traffic either there to pods. K8s provides readiness probes to detect and mitigate these situations. A pod with containers reporting that they are not ready does not receive traffic through Kubernetes Services.

这篇关于当Pod处于“忙碌"状态时,指定给Kubernetes.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆