如何将一些容器与 Kubernetes Horizo​​ntal Pod Autoscaler 隔离

How to isolate some Containers from Kubernetes Horizontal Pod Autoscaler

使用 Horizo​​ntal Pod Autoscaler 实现 Deployment 运行 Pod 有两个不同的容器:Containers-AContaner-B,我想确保它只缩放 Containers-A 的数量。 Container-B 的数量应该始终相同,并且不受 Pod 的 Autoscaler 的影响。我想知道是否可以将 Container-B 与 Autoscaler 隔离。如果可以,如何实现?

kubectl autoscale my-deployment --min=10 --max=15 --cpu-percent=80

顾名思义 "Horizontal Pod Autoscaler" 秤 pods,而不是容器。

但是,我看不出您想要这种行为的原因。

You should have more than one container in a Pod only if those containers are tightly coupled together and need to share resources. 您想独立扩展容器 A 和 B 的事实告诉我,这些容器并没有紧密耦合。

我建议采用以下方法:

  1. 使用容器 A 管理 Pods 的部署 A。 Autoscaler 将仅为此部署缩放 pods。

  2. 使用容器 B 管理 Pods 的部署 B。此部署不会受到自动缩放器的影响。