@@ -129,7 +129,7 @@ Kubernetes 将水平 Pod 自动扩缩实现为一个间歇运行的控制回路
129
129
130
130
<!--
131
131
Once during each period, the controller manager queries the resource utilization against the
132
- metrics specified in each HorizontalPodAutoscaler definition. The controller manager
132
+ metrics specified in each HorizontalPodAutoscaler definition. The controller manager
133
133
finds the target resource defined by the `scaleTargetRef`,
134
134
then selects the pods based on the target resource's `.spec.selector` labels, and obtains the metrics from either the resource metrics API (for per-pod resource metrics),
135
135
or the custom metrics API (for all other metrics).
@@ -144,7 +144,7 @@ or the custom metrics API (for all other metrics).
144
144
Then, if a target utilization value is set, the controller calculates the utilization
145
145
value as a percentage of the equivalent
146
146
[resource request](/docs/concepts/configuration/manage-resources-containers/#requests-and-limits)
147
- on the containers in each Pod. If a target raw value is set, the raw metric values are used directly.
147
+ on the containers in each Pod. If a target raw value is set, the raw metric values are used directly.
148
148
The controller then takes the mean of the utilization or the raw value (depending on the type
149
149
of target specified) across all targeted Pods, and produces a ratio used to scale
150
150
the number of desired replicas.
@@ -184,7 +184,7 @@ or the custom metrics API (for all other metrics).
184
184
<!--
185
185
The common use for HorizontalPodAutoscaler is to configure it to fetch metrics from
186
186
{{< glossary_tooltip text="aggregated APIs" term_id="aggregation-layer" >}}
187
- (`metrics.k8s.io`, `custom.metrics.k8s.io`, or `external.metrics.k8s.io`). The `metrics.k8s.io` API is
187
+ (`metrics.k8s.io`, `custom.metrics.k8s.io`, or `external.metrics.k8s.io`). The `metrics.k8s.io` API is
188
188
usually provided by an add-on named Metrics Server, which needs to be launched separately.
189
189
For more information about resource metrics, see
190
190
[Metrics Server](/docs/tasks/debug/debug-cluster/resource-metrics-pipeline/#metrics-server).
@@ -235,7 +235,7 @@ desiredReplicas = ceil[currentReplicas * ( currentMetricValue / desiredMetricVal
235
235
For example, if the current metric value is `200m`, and the desired value
236
236
is `100m`, the number of replicas will be doubled, since `200.0 / 100.0 ==
237
237
2.0` If the current value is instead `50m`, you'll halve the number of
238
- replicas, since `50.0 / 100.0 == 0.5`. The control plane skips any scaling
238
+ replicas, since `50.0 / 100.0 == 0.5`. The control plane skips any scaling
239
239
action if the ratio is sufficiently close to 1.0 (within a globally-configurable
240
240
tolerance, 0.1 by default).
241
241
-->
@@ -274,7 +274,7 @@ with missing metrics will be used to adjust the final scaling amount.
274
274
275
275
<!--
276
276
When scaling on CPU, if any pod has yet to become ready (it's still
277
- initializing, or possibly is unhealthy) *or* the most recent metric point for
277
+ initializing, or possibly is unhealthy) _or_ the most recent metric point for
278
278
the pod was before it became ready, that pod is set aside as well.
279
279
-->
280
280
当使用 CPU 指标来扩缩时,任何还未就绪(还在初始化,或者可能是不健康的)状态的 Pod ** 或**
@@ -287,7 +287,7 @@ determining whether to set aside certain CPU metrics. Instead, it
287
287
considers a Pod "not yet ready" if it's unready and transitioned to
288
288
ready within a short, configurable window of time since it started.
289
289
This value is configured with the `--horizontal-pod-autoscaler-initial-readiness-delay` flag, and its default is 30
290
- seconds. Once a pod has become ready, it considers any transition to
290
+ seconds. Once a pod has become ready, it considers any transition to
291
291
ready to be the first if it occurred within a longer, configurable time
292
292
since it started. This value is configured with the `--horizontal-pod-autoscaler-cpu-initialization-period` flag, and its
293
293
default is 5 minutes.
@@ -308,7 +308,7 @@ calculated using the remaining pods not set aside or discarded from above.
308
308
<!--
309
309
If there were any missing metrics, the control plane recomputes the average more
310
310
conservatively, assuming those pods were consuming 100% of the desired
311
- value in case of a scale down, and 0% in case of a scale up. This dampens
311
+ value in case of a scale down, and 0% in case of a scale up. This dampens
312
312
the magnitude of any potential scale.
313
313
-->
314
314
如果缺失某些度量值,控制平面会更保守地重新计算平均值,在需要缩小时假设这些 Pod 消耗了目标值的 100%,
@@ -325,7 +325,7 @@ of the desired metric, further dampening the magnitude of a scale up.
325
325
326
326
<!--
327
327
After factoring in the not-yet-ready pods and missing metrics, the
328
- controller recalculates the usage ratio. If the new ratio reverses the scale
328
+ controller recalculates the usage ratio. If the new ratio reverses the scale
329
329
direction, or is within the tolerance, the controller doesn't take any scaling
330
330
action. In other cases, the new ratio is used to decide any change to the
331
331
number of Pods.
@@ -335,7 +335,7 @@ number of Pods.
335
335
在其他情况下,新比率用于决定对 Pod 数量的任何更改。
336
336
337
337
<!--
338
- Note that the *original* value for the average utilization is reported
338
+ Note that the _original_ value for the average utilization is reported
339
339
back via the HorizontalPodAutoscaler status, without factoring in the
340
340
not-yet-ready pods or missing metrics, even when the new usage ratio is
341
341
used.
@@ -360,7 +360,7 @@ the current value.
360
360
这表示,如果一个或多个指标给出的 ` desiredReplicas ` 值大于当前值,HPA 仍然能实现扩容。
361
361
362
362
<!--
363
- Finally, right before HPA scales the target, the scale recommendation is recorded. The
363
+ Finally, right before HPA scales the target, the scale recommendation is recorded. The
364
364
controller considers all recommendations within a configurable window choosing the
365
365
highest recommendation from within that window. This value can be configured using the `--horizontal-pod-autoscaler-downscale-stabilization` flag, which defaults to 5 minutes.
366
366
This means that scaledowns will occur gradually, smoothing out the impact of rapidly
@@ -377,7 +377,7 @@ fluctuating metric values.
377
377
## API Object
378
378
379
379
The Horizontal Pod Autoscaler is an API resource in the Kubernetes
380
- `autoscaling` API group. The current stable version can be found in
380
+ `autoscaling` API group. The current stable version can be found in
381
381
the `autoscaling/v2` API version which includes support for scaling on
382
382
memory and custom metrics. The new fields introduced in
383
383
`autoscaling/v2` are preserved as annotations when working with
@@ -405,8 +405,8 @@ More details about the API object can be found at
405
405
406
406
When managing the scale of a group of replicas using the HorizontalPodAutoscaler,
407
407
it is possible that the number of replicas keeps fluctuating frequently due to the
408
- dynamic nature of the metrics evaluated. This is sometimes referred to as *thrashing* ,
409
- or *flapping* . It's similar to the concept of *hysteresis* in cybernetics.
408
+ dynamic nature of the metrics evaluated. This is sometimes referred to as _thrashing_ ,
409
+ or _flapping_ . It's similar to the concept of _hysteresis_ in cybernetics.
410
410
-->
411
411
## 工作量规模的稳定性 {#flapping}
412
412
@@ -614,7 +614,7 @@ HorizontalPodAutoscaler 采用为每个指标推荐的最大比例,
614
614
<!--
615
615
# # Support for metrics APIs
616
616
617
- By default, the HorizontalPodAutoscaler controller retrieves metrics from a series of APIs. In order for it to access these
617
+ By default, the HorizontalPodAutoscaler controller retrieves metrics from a series of APIs. In order for it to access these
618
618
APIs, cluster administrators must ensure that :
619
619
-->
620
620
# # 对 Metrics API 的支持 {#support-for-metrics-apis}
@@ -628,25 +628,25 @@ APIs, cluster administrators must ensure that:
628
628
* The corresponding APIs are registered:
629
629
630
630
* For resource metrics, this is the `metrics.k8s.io` API, generally provided by [metrics-server](https://github.com/kubernetes-sigs/metrics-server).
631
- It can be launched as a cluster add-on.
631
+ It can be launched as a cluster add-on.
632
632
633
633
* For custom metrics, this is the `custom.metrics.k8s.io` API. It's provided by "adapter" API servers provided by metrics solution vendors.
634
- Check with your metrics pipeline to see if there is a Kubernetes metrics adapter available.
634
+ Check with your metrics pipeline to see if there is a Kubernetes metrics adapter available.
635
635
636
636
* For external metrics, this is the `external.metrics.k8s.io` API. It may be provided by the custom metrics adapters provided above.
637
637
-->
638
638
* 启用了 [API 聚合层](/zh-cn/docs/tasks/extend-kubernetes/configure-aggregation-layer/)
639
639
640
640
* 相应的 API 已注册:
641
641
642
- * 对于资源指标,将使用 `metrics.k8s.io` API,一般由 [metrics-server](https://github.com/kubernetes-incubator/metrics-server) 提供。
642
+ * 对于资源指标,将使用 `metrics.k8s.io` API,一般由 [metrics-server](https://github.com/kubernetes-incubator/metrics-server) 提供。
643
643
它可以作为集群插件启动。
644
644
645
- * 对于自定义指标,将使用 `custom.metrics.k8s.io` API。
645
+ * 对于自定义指标,将使用 `custom.metrics.k8s.io` API。
646
646
它由其他度量指标方案厂商的“适配器(Adapter)” API 服务器提供。
647
647
检查你的指标管道以查看是否有可用的 Kubernetes 指标适配器。
648
648
649
- * 对于外部指标,将使用 `external.metrics.k8s.io` API。可能由上面的自定义指标适配器提供。
649
+ * 对于外部指标,将使用 `external.metrics.k8s.io` API。可能由上面的自定义指标适配器提供。
650
650
651
651
<!--
652
652
For more information on these different metrics paths and how they differ please see the relevant design proposals for
@@ -918,6 +918,7 @@ behavior:
918
918
scaleDown:
919
919
selectPolicy: Disabled
920
920
` ` `
921
+
921
922
<!--
922
923
# # Support for HorizontalPodAutoscaler in kubectl
923
924
@@ -936,7 +937,7 @@ Finally, you can delete an autoscaler using `kubectl delete hpa`.
936
937
<!--
937
938
In addition, there is a special `kubectl autoscale` command for creating a HorizontalPodAutoscaler object.
938
939
For instance, executing `kubectl autoscale rs foo --min=2 --max=5 --cpu-percent=80`
939
- will create an autoscaler for ReplicaSet *foo* , with target CPU utilization set to `80%`
940
+ will create an autoscaler for ReplicaSet _foo_ , with target CPU utilization set to `80%`
940
941
and the number of replicas between 2 and 5.
941
942
-->
942
943
此外,还有一个特殊的 `kubectl autoscale` 命令用于创建 HorizontalPodAutoscaler 对象。
@@ -948,7 +949,7 @@ and the number of replicas between 2 and 5.
948
949
949
950
You can implicitly deactivate the HPA for a target without the
950
951
need to change the HPA configuration itself. If the target's desired replica count
951
- is set to 0, and the HPA's minimum replica count is greater than 0, the HPA
952
+ is set to 0, and the HPA's minimum replica count is greater than 0, the HPA
952
953
stops adjusting the target (and sets the `ScalingActive` Condition on itself
953
954
to `false`) until you reactivate it by manually adjusting the target's desired
954
955
replica count or HPA's minimum replica count.
@@ -965,7 +966,7 @@ replica count or HPA's minimum replica count.
965
966
966
967
When an HPA is enabled, it is recommended that the value of `spec.replicas` of
967
968
the Deployment and / or StatefulSet be removed from their
968
- {{< glossary_tooltip text="manifest(s)" term_id="manifest" >}}. If this isn't done, any time
969
+ {{< glossary_tooltip text="manifest(s)" term_id="manifest" >}}. If this isn't done, any time
969
970
a change to that object is applied, for example via `kubectl apply -f
970
971
deployment.yaml`, this will instruct Kubernetes to scale the current number of Pods
971
972
to the value of the `spec.replicas` key. This may not be
@@ -984,9 +985,9 @@ Deployment 和/或 StatefulSet 的 `spec.replicas` 的值。
984
985
Keep in mind that the removal of `spec.replicas` may incur a one-time
985
986
degradation of Pod counts as the default value of this key is 1 (reference
986
987
[Deployment Replicas](/docs/concepts/workloads/controllers/deployment#replicas)).
987
- Upon the update, all Pods except 1 will begin their termination procedures. Any
988
+ Upon the update, all Pods except 1 will begin their termination procedures. Any
988
989
deployment application afterwards will behave as normal and respect a rolling
989
- update configuration as desired. You can avoid this degradation by choosing one of the following two
990
+ update configuration as desired. You can avoid this degradation by choosing one of the following two
990
991
methods based on how you are modifying your deployments :
991
992
-->
992
993
请记住,删除 `spec.replicas` 可能会导致 Pod 计数一次性降级,因为此键的默认值为 1
@@ -1000,10 +1001,10 @@ methods based on how you are modifying your deployments:
1000
1001
<!--
1001
1002
1. `kubectl apply edit-last-applied deployment/<deployment_name>`
1002
1003
2. In the editor, remove `spec.replicas`. When you save and exit the editor, `kubectl`
1003
- applies the update. No changes to Pod counts happen at this step.
1004
+ applies the update. No changes to Pod counts happen at this step.
1004
1005
3. You can now remove `spec.replicas` from the manifest. If you use source code management,
1005
- also commit your changes or take whatever other steps for revising the source code
1006
- are appropriate for how you track updates.
1006
+ also commit your changes or take whatever other steps for revising the source code
1007
+ are appropriate for how you track updates.
1007
1008
4. From here on out you can run `kubectl apply -f deployment.yaml`
1008
1009
-->
1009
1010
1. `kubectl apply edit-last-applied deployment/<Deployment 名称>`
@@ -1053,4 +1054,3 @@ For more information on HorizontalPodAutoscaler:
1053
1054
* 如果你想编写自己的自定义指标适配器,
1054
1055
请查看 [boilerplate](https://github.com/kubernetes-sigs/custom-metrics-apiserver) 以开始使用。
1055
1056
* 阅读 [API 参考](/zh-cn/docs/reference/kubernetes-api/workload-resources/horizontal-pod-autoscaler-v2/)。
1056
-
0 commit comments