简体   繁体   English

在未就绪的状态下保持Kubernetes Pod处于服务状态

[英]Keep a Kubernetes Pod in service when in a state of not ready

I am working on a project currently migrating a legacy application towards becoming cloud-compliant. 我正在做一个项目,目前正在将旧版应用程序迁移到符合云的要求。 We are using Kubernetes, Openshift and Docker for this. 我们为此使用Kubernetes,Openshift和Docker。 The application has one particular type of "back-end pod" (let's call it BEP) whose responsibility it is to process incoming transactions. 该应用程序具有一种特殊类型的“后端容器”(简称为BEP),其职责是处理传入的事务。 In this pod we have several interdependent containers, but only one container which actually does the "real processing" (call it BEC). 在此容器中,我们有几个相互依赖的容器,但是只有一个容器实际执行“实际处理”(称为BEC)。 This legacy application processes several thousands of transactions / sec, and will need to continue to do so in the cloud. 这个旧版应用程序每秒处理数千个事务,因此需要继续在云中进行。

To achieve this scale we were thinking to duplicate the BEC in the pod instead of replicating the BEP (and thus also replicating all the other unnecessary containers that come along with it). 为了达到这种规模,我们正在考虑在容器中复制BEC,而不是复制BEP(因此也复制了它随附的所有其他不必要的容器)。 We might need X replicas of this BEC, whereas we would not need to scale its interdependent containers at all. 我们可能需要此BEC的X个副本,而我们根本不需要扩展其相互依赖的容器。 It would thus be useless to scale X replicas of the BEP instead. 因此,缩放BEP的X个副本将毫无用处。

However, this solution poses a problem. 但是,该解决方案带来了问题。 Once one BEC is down the entire pod will be flagged as "Not ready" by kubernetes (even if there are 100 other BEC's which are up and ready to process) upon which the pod end-point is removed and thus cutting the traffic to the entire pod. 一旦一个BEC掉线,kubernetes(即使还有100个其他BEC已启动并准备处理)将被kubernetes标记为“未准备好”,从而移除了pod端点,从而减少了到整个豆荚。

I guess this is a classical example of defining some sort of "minimum running requirement" for the pod. 我猜这是为吊舱定义某种“最低运行要求”的经典示例。

I thus have two questions: 因此,我有两个问题:

  • Is there a way to flag a pod as still functioning even if all containers are not in a state of "ready"? 即使所有容器都不处于“就绪”状态,有没有办法将吊舱标记为仍在工作? Ie achieving this minimum running requirement by defining a lower threshold on the # containers in a state of "ready" for the pod to be considered functioning? 通过在“准备就绪”状态下的#个容器上定义一个较低的阈值来实现该最低运行要求,以使吊舱能够正常工作?
  • Is there a way to maybe flag the service - that the pod provides - as to still send traffic even if the pod is not in a ready state? 是否有一种方法可以标记Pod提供的服务,即使Pod未处于就绪状态也可以继续发送流量? I have seen an property called: publishNotReadyAddresses ( https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/#servicespec-v1-core#publishNotReadyAddresses ) but I am unsure if this does what we would require? 我已经看到了一个名为publishNotReadyAddresses的属性( https://kubernetes.io/docs/reference/produced/kubernetes-api/v1.10/#servicespec-v1-core#publishNotReadyAddresses ),但是我不确定这是否可以做到要求?

If the answer to both of these two questions is a no: do you have any idea / approach to take concerning this problem, without proposing a major architectural refactoring of this legacy application? 如果对这两个问题的回答都是“否”:您是否有任何想法/方法来解决这个问题,而没有建议对该遗留应用程序进行主要的体系结构重构? We can not split the interdependent containers from the BEC, they need to run in the same pod...unfortunately. 我们不能从BEC中拆分出相互依赖的容器,不幸的是它们需要在同一容器中运行。

Thanks in advance for any help/advice! 预先感谢您的任何帮助/建议!

/Alex /亚历克斯

Is there a way to flag a pod as still functioning even if all containers are not in a state of "ready"? 即使所有容器都不处于“就绪”状态,有没有办法将吊舱标记为仍在工作? Ie achieving this minimum running requirement by defining a lower threshold on the # containers in a state of "ready" for the pod to be considered functioning? 通过在“准备就绪”状态下的#个容器上定义一个较低的阈值来实现该最低运行要求,以使吊舱能够正常工作?

No, this is not possible. 不,这是不可能的。

You can use annotations : 您可以使用注释

metadata:
  name: name
  labels:
    app: app
  annotations:
    service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"

But community is already working on this issue/bug, you can follow #58662 and #49239 但是社区已经在解决这个问题/错误,您可以按照#58662#49239

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

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