Kubernetes hpa 补丁命令不起作用

Kuberenetes hpa patch command not working

我在 Google 云中托管了 Kuberenetes 集群。

我部署了部署并添加了 hpa 扩展规则。

kubectl autoscale deployment MY_DEP --max 10 --min 6 --cpu-percent 60

等一下,然后 运行 kubectl get hpa 命令来验证我的缩放规则 - 正如预期的那样,我有 6 pods 运行ning(根据最小参数)。

$ kubectl get hpa
NAME                    REFERENCE                          TARGETS         MINPODS   MAXPODS   REPLICAS   AGE
MY_DEP                  Deployment/MY_DEP                  <unknown>/60%   6         10        6          1m

现在,我想更改最小参数:

kubectl patch hpa MY_DEP -p '{"spec":{"minReplicas": 1}}'

等待 30 分钟,运行 命令:

$ kubectl get hpa
NAME                    REFERENCE                          TARGETS         MINPODS   MAXPODS   REPLICAS   AGE
MY_DEP                  Deployment/MY_DEP                  <unknown>/60%   1         10        6          30m

预期副本数:1,实际副本数:6

更多信息:

  1. 你可以假设系统没有计算任何东西 (0% CPU 利用率)。
  2. 等了一个多小时。没有改变。
  3. 当我删除缩放规则并部署它时出现相同的行为 再次。 replicas 参数没有改变。

问题:

如果我将 MINPODS 参数更改为“1” - 为什么我仍然有 6 pods?如何让 Kubernetes 在我的部署中实际更改 min pods?

If I changed the MINPODS parameter to "1" - why I still have 6 pods?

我相信答案是因为输出中存在 <unknown>/60%The fine manual 状态:

Please note that if some of the pod's containers do not have the relevant resource request set, CPU utilization for the pod will not be defined and the autoscaler will not take any action for that metric

并且可以在 the walkthrough page 中看到 0% / 50% 的示例。因此,我认为,由于 kubernetes 无法证明 的 CPU 百分比被消耗——既不高于也不低于目标——它不采取任何行动,因为害怕 [= =23=]随便情况更糟。

至于为什么会有 <unknown>,我敢猜测这是可怕的堆到指标服务器的转换,可能混淆了来自 kubernetes 的信息 API。遗憾的是,我没有测试该理论的第一手经验,无法为您提供超越 "see if your cluster is collecting metrics in a place that kubernetes can see them."

的具体步骤