Kubernetes:更改 hpa min-replica

Kubenetes: change hpa min-replica

我在 Google 云中托管了 Kubernetes 集群。我创建了一个部署并为其定义了一个 hpa 规则:

kubectl autoscale deployment my_deployment --min 6 --max 30 --cpu-percent 80

我想 运行 编辑 --min 值的命令,无需删除并重新创建新的 hpa 规则。类似于:

$ kubectl autoscale deployment my_deployment --min 1 --max 30
Error from server (AlreadyExists): horizontalpodautoscalers.autoscaling "my_deployment" already exists

是否可以在命令行上编辑 hpa(最小值、最大值、cpu-百分比、...)?

Is this possible to edit hpa (min, max, cpu-percent, ...) on command line?

它们可以像任何其他资源一样进行编辑,尽管可以 kubectl edit hpa $the_hpa_name 进行交互式编辑,或者 kubectl patch hpa $the_hpa_name -p '{"spec":{"minReplicas": 1}}' 在 "batch" 设置中进行编辑。

如果您不知道 $the_hpa_name,您可以像任何其他资源一样获取它们的列表:kubectl get hpa,同样您可以使用 [=14] 查看当前设置和状态=](甚至可以省略 $the_hpa_name 以查看所有内容,但这可能会包含很多文本,具体取决于您的集群设置)。