HPA + Cluster Autoscaler + GKE 上 Federated Kubernetes 集群中的 OPA

HPA + Cluster Autoscaler + OPA within Federated Kubernetes cluster on GKE

我正在 Google 容器引擎 (GKE) 1.8.3-gke.0 上使用 kubefed 设置联合 kubernetes 集群。

而且看起来不错 HPA and cluster autoscaler I have to use Open Policy Agent as a kubernetes Admission Controller because of this:

By default, replicas are spread equally in all the underlying clusters. For example: if you have 3 registered clusters and you create a Federated Deployment with spec.replicas = 9, then each Deployment in the 3 clusters will have spec.replicas=3.

但在我的例子中,每个区域的负载都会动态变化,每个集群都应该有动态的 pods 数字。

我找不到(或根本看不到)有关像我这样的案例的示例或手册。所以,问题是:

如果我的联合上下文中有三个集群,每个 GKE 区域一个集群,策略应该有什么场景:

它应该是 动态地 分布 pods 到这三个集群的单一部署。

一个pod应该:

如果可能的话,我如何配置 OPA 以使该模式起作用?

提前感谢您提供相应手册的任何链接。

您尝试做的事情应该可以通过 "Federated Horizontal Pod Autoscalers" 实现,他们的主要用例之一正是您的场景:

引用自 Federated Pod Autoscaler 的 Requirements & Design Document

Users can schedule replicas of same application, across the federated clusters, using replicaset (or deployment). Users however further might need to let the replicas be scaled independently in each cluster, depending on the current usage metrics of the replicas; including the CPU, memory and application defined custom metrics.

并且从 actual documentation 结论中的这段话描述了行为:

The use of federated HPA is to ensure workload replicas move to the cluster(s) where they are needed most, or in other words where the load is beyond expected threshold. The federated HPA feature achieves this by manipulating the min and max replicas on the HPAs it creates in the federated clusters. It actually relies on the in-cluster HPA controllers to monitor the metrics and update relevant fields [...] The federated HPA controller, on the other hand, monitors only the cluster-specific HPA object fields and updates the min replica and max replica fields of those in cluster HPA objects, which have replicas matching thresholds.

因此,如果我没有误解您的需求,就没有理由使用 Open Policy Agent 等第三方产品或创建策略。