@@ -32,12 +32,12 @@ This is different from _vertical_ scaling, which for Kubernetes would mean
32
32
assigning more resources (for example: memory or CPU) to the Pods that are already
33
33
running for the workload.
34
34
-->
35
- [ HorizontalPodAutoscaler] ( /zh-cn/docs/tasks/run-application/horizontal-pod-autoscale/ ) (简称 HPA )
35
+ [ HorizontalPodAutoscaler] ( /zh-cn/docs/tasks/run-application/horizontal-pod-autoscale/ ) (简称 HPA )
36
36
自动更新工作负载资源(例如 {{< glossary_tooltip text="Deployment" term_id="deployment" >}} 或者
37
37
{{< glossary_tooltip text="StatefulSet" term_id="statefulset" >}}),
38
38
目的是自动扩缩工作负载以满足需求。
39
39
40
- 水平扩缩意味着对增加的负载的响应是部署更多的 {{< glossary_tooltip text="Pods " term_id="pod" >}}。
40
+ 水平扩缩意味着对增加的负载的响应是部署更多的 {{< glossary_tooltip text="Pod " term_id="pod" >}}。
41
41
这与 “垂直(Vertical)” 扩缩不同,对于 Kubernetes,
42
42
垂直扩缩意味着将更多资源(例如:内存或 CPU)分配给已经为工作负载运行的 Pod。
43
43
@@ -51,7 +51,7 @@ automatically manage scale for an example web app. This example workload is Apac
51
51
httpd running some PHP code.
52
52
-->
53
53
如果负载减少,并且 Pod 的数量高于配置的最小值,
54
- HorizontalPodAutoscaler 会指示工作负载资源( Deployment、StatefulSet 或其他类似资源)缩减。
54
+ HorizontalPodAutoscaler 会指示工作负载资源(Deployment、StatefulSet 或其他类似资源)缩减。
55
55
56
56
本文档将引导你完成启用 HorizontalPodAutoscaler 以自动管理示例 Web 应用程序的扩缩的示例。
57
57
此示例工作负载是运行一些 PHP 代码的 Apache httpd。
@@ -97,44 +97,12 @@ Kubernetes Metrics Server 从集群中的 {{<glossary_tooltip term_id="kubelet"
97
97
## 运行 php-apache 服务器并暴露服务 {#run-and-expose-php-apache-server}
98
98
99
99
<!--
100
- To demonstrate a HorizontalPodAutoscaler, you will first make a custom container image that uses
101
- the `php-apache` image from Docker Hub as its starting point. The `Dockerfile` is ready-made for you,
102
- and has the following content:
103
- -->
104
- 为了演示 HorizontalPodAutoscaler,你将首先制作一个自定义容器镜像,
105
- 该镜像使用来自 Docker Hub 的 ` php-apache ` 镜像作为其起点。
106
- ` Dockerfile ` 已经为你准备好了,内容如下:
107
-
108
- ``` dockerfile
109
- FROM php:5-apache
110
- COPY index.php /var/www/html/index.php
111
- RUN chmod a+rx index.php
112
- ```
113
-
114
- <!--
115
- This code defines a simple `index.php` page that performs some CPU intensive computations,
116
- in order to simulate load in your cluster.
117
- -->
118
- 代码定义了一个简单的 ` index.php ` 页面,该页面执行一些 CPU 密集型计算,
119
- 以模拟集群中的负载。
120
-
121
- ``` php
122
- <?php
123
- $x = 0.0001;
124
- for ($i = 0; $i <= 1000000; $i++) {
125
- $x += sqrt($x);
126
- }
127
- echo "OK!";
128
- ?>
129
- ```
130
-
131
- <!--
132
- Once you have made that container image, start a Deployment that runs a container using the
133
- image you made, and expose it as a {{< glossary_tooltip term_id="service">}}
100
+ To demonstrate a HorizontalPodAutoscaler, you will first start a Deployment that runs a container using the
101
+ `hpa-example` image, and expose it as a {{< glossary_tooltip term_id="service">}}
134
102
using the following manifest:
135
103
-->
136
- 制作完该容器镜像后,使用你制作的镜像启动运行一个容器的 Deployment,
137
- 并使用以下清单将其公开为 {{< glossary_tooltip term_id="service" text="服务" >}}:
104
+ 为了演示 HorizontalPodAutoscaler,你将首先启动一个 Deployment 用 ` hpa-example ` 镜像运行一个容器 ,
105
+ 然后使用以下清单文件将其暴露为一个 {{< glossary_tooltip term_id="service">}}:
138
106
139
107
{{< codenew file="application/php-apache.yaml" >}}
140
108
@@ -398,7 +366,7 @@ kubectl get hpa php-apache -o yaml > /tmp/hpa-v2.yaml
398
366
<!--
399
367
Open the `/tmp/hpa-v2.yaml` file in an editor, and you should see YAML which looks like this:
400
368
-->
401
- 在编辑器中打开 ` /tmp/hpa-v2.yaml ` :
369
+ 在编辑器中打开 ` /tmp/hpa-v2.yaml ` ,你应看到如下所示的 YAML 文件 :
402
370
403
371
``` yaml
404
372
apiVersion : autoscaling/v2
@@ -475,7 +443,7 @@ They work much like resource metrics, except that they *only* support a `target`
475
443
<!--
476
444
Pod metrics are specified using a metric block like this :
477
445
-->
478
- pod 度量指标通过如下代码块定义:
446
+ Pod 度量指标通过如下代码块定义:
479
447
480
448
` ` ` yaml
481
449
type: Pods
@@ -496,8 +464,8 @@ metric from the API. With `AverageValue`, the value returned from the custom met
496
464
by the number of Pods before being compared to the target. The following example is the YAML
497
465
representation of the `requests-per-second` metric.
498
466
-->
499
- 第二种可选的度量指标类型是对象 **(Object)度量指标**。这些度量指标用于描述
500
- 在相同名字空间中的别的对象 ,而非 Pods 。
467
+ 第二种可选的度量指标类型是对象 **(Object)度量指标**。
468
+ 这些度量指标用于描述在相同名字空间中的别的对象 ,而非 Pod 。
501
469
请注意这些度量指标不一定来自某对象,它们仅用于描述这些对象。
502
470
对象度量指标支持的 `target` 类型包括 `Value` 和 `AverageValue`。
503
471
如果是 `Value` 类型,`target` 值将直接与 API 返回的度量指标比较,
@@ -531,8 +499,8 @@ HorizontalPodAutoscaler 将会计算每一个指标所提议的副本数量,
531
499
For example, if you had your monitoring system collecting metrics about network traffic,
532
500
you could update the definition above using `kubectl edit` to look like this :
533
501
-->
534
- 比如,如果你的监控系统能够提供网络流量数据,你可以通过 `kubectl edit` 命令
535
- 将上述 Horizontal Pod Autoscaler 的定义更改为:
502
+ 比如,如果你的监控系统能够提供网络流量数据,你可以通过 `kubectl edit`
503
+ 命令将上述 Horizontal Pod Autoscaler 的定义更改为:
536
504
537
505
` ` ` yaml
538
506
apiVersion: autoscaling/v2
@@ -615,7 +583,7 @@ label, you can specify the following metric block to scale only on GET requests:
615
583
-->
616
584
# ## 基于更特别的度量值来扩缩 {#autoscaing-on-more-specific-metrics}
617
585
618
- 许多度量流水线允许你通过名称或附加的 _标签_ 来描述度量指标。
586
+ 许多度量流水线允许你通过名称或附加的 **标签** 来描述度量指标。
619
587
对于所有非资源类型度量指标(Pod、Object 和后面将介绍的 External),
620
588
可以额外指定一个标签选择算符。例如,如果你希望收集包含 `verb` 标签的
621
589
` http_requests` 度量指标,可以按如下所示设置度量指标块,使得扩缩操作仅针对
@@ -638,8 +606,7 @@ type, and the described object in the case of the `Object` type).
638
606
-->
639
607
这个选择算符使用与 Kubernetes 标签选择算符相同的语法。
640
608
如果名称和标签选择算符匹配到多个系列,监测管道会决定如何将多个系列合并成单个值。
641
- 选择算符是可以累加的,它不会选择目标以外的对象(类型为 `Pods` 的目标 Pods 或者
642
- 类型为 `Object` 的目标对象)。
609
+ 选择算符是可以累加的,它不会选择目标以外的对象(类型为 `Pods` 的目标 Pod 或者类型为 `Object` 的目标对象)。
643
610
644
611
<!--
645
612
# ## Autoscaling on metrics not related to Kubernetes objects
@@ -651,8 +618,8 @@ with *external metrics*.
651
618
-->
652
619
# ## 基于与 Kubernetes 对象无关的度量指标执行扩缩 {#autoscaling-on-metrics-not-related-to-kubernetes-objects}
653
620
654
- 运行在 Kubernetes 上的应用程序可能需要基于与 Kubernetes 集群中的任何对象
655
- 没有明显关系的度量指标进行自动扩缩 ,
621
+ 运行在 Kubernetes 上的应用程序可能需要基于与 Kubernetes
622
+ 集群中的任何对象没有明显关系的度量指标进行自动扩缩 ,
656
623
例如那些描述与任何 Kubernetes 名字空间中的服务都无直接关联的度量指标。
657
624
在 Kubernetes 1.10 及之后版本中,你可以使用外部度量指标(external metrics)。
658
625
@@ -781,12 +748,11 @@ between `1` and `1500m`, or `1` and `1.5` when written in decimal notation.
781
748
-->
782
749
## 量纲 {#quantities}
783
750
784
- HorizontalPodAutoscaler 和 度量指标 API 中的所有的度量指标使用 Kubernetes 中称为
785
- {{< glossary_tooltip term_id="quantity" text="量纲(Quantity)">}}
786
- 的特殊整数表示。
751
+ HorizontalPodAutoscaler 和 度量指标 API 中的所有的度量指标使用 Kubernetes
752
+ 中称为{{< glossary_tooltip term_id="quantity" text="量纲(Quantity)">}}的特殊整数表示。
787
753
例如,数量 `10500m` 用十进制表示为 `10.5`。
788
754
如果可能的话,度量指标 API 将返回没有后缀的整数,否则返回以千分单位的数量。
789
- 这意味着你可能会看到你的度量指标在 `1` 和 `1500m` (也就是在十进制记数法中的 `1` 和 `1.5`)之间波动。
755
+ 这意味着你可能会看到你的度量指标在 `1` 和 `1500m`(也就是在十进制记数法中的 `1` 和 `1.5`)之间波动。
790
756
791
757
<!--
792
758
## Other possible scenarios
@@ -808,7 +774,7 @@ can use the following manifest to create it declaratively:
808
774
<!--
809
775
Then, create the autoscaler by executing the following command:
810
776
-->
811
- 使用如下命令创建 autoscaler :
777
+ 使用如下命令创建 Autoscaler :
812
778
813
779
```shell
814
780
kubectl create -f https://k8s.io/examples/application/hpa/php-apache.yaml
0 commit comments