Skip to content

Commit 12d9b2c

Browse files
author
zhuzhenghao
committed
[zh] sync run-single-instance-stateful-application
1 parent e244bf9 commit 12d9b2c

File tree

2 files changed

+62
-55
lines changed

2 files changed

+62
-55
lines changed

content/zh-cn/docs/tasks/run-application/horizontal-pod-autoscale.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Kubernetes 将水平 Pod 自动扩缩实现为一个间歇运行的控制回路
129129

130130
<!--
131131
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
133133
finds the target resource defined by the `scaleTargetRef`,
134134
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),
135135
or the custom metrics API (for all other metrics).
@@ -144,7 +144,7 @@ or the custom metrics API (for all other metrics).
144144
Then, if a target utilization value is set, the controller calculates the utilization
145145
value as a percentage of the equivalent
146146
[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.
148148
The controller then takes the mean of the utilization or the raw value (depending on the type
149149
of target specified) across all targeted Pods, and produces a ratio used to scale
150150
the number of desired replicas.
@@ -184,7 +184,7 @@ or the custom metrics API (for all other metrics).
184184
<!--
185185
The common use for HorizontalPodAutoscaler is to configure it to fetch metrics from
186186
{{< 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
188188
usually provided by an add-on named Metrics Server, which needs to be launched separately.
189189
For more information about resource metrics, see
190190
[Metrics Server](/docs/tasks/debug/debug-cluster/resource-metrics-pipeline/#metrics-server).
@@ -235,7 +235,7 @@ desiredReplicas = ceil[currentReplicas * ( currentMetricValue / desiredMetricVal
235235
For example, if the current metric value is `200m`, and the desired value
236236
is `100m`, the number of replicas will be doubled, since `200.0 / 100.0 ==
237237
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
239239
action if the ratio is sufficiently close to 1.0 (within a globally-configurable
240240
tolerance, 0.1 by default).
241241
-->
@@ -274,7 +274,7 @@ with missing metrics will be used to adjust the final scaling amount.
274274

275275
<!--
276276
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
278278
the pod was before it became ready, that pod is set aside as well.
279279
-->
280280
当使用 CPU 指标来扩缩时,任何还未就绪(还在初始化,或者可能是不健康的)状态的 Pod ****
@@ -287,7 +287,7 @@ determining whether to set aside certain CPU metrics. Instead, it
287287
considers a Pod "not yet ready" if it's unready and transitioned to
288288
ready within a short, configurable window of time since it started.
289289
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
291291
ready to be the first if it occurred within a longer, configurable time
292292
since it started. This value is configured with the `--horizontal-pod-autoscaler-cpu-initialization-period` flag, and its
293293
default is 5 minutes.
@@ -308,7 +308,7 @@ calculated using the remaining pods not set aside or discarded from above.
308308
<!--
309309
If there were any missing metrics, the control plane recomputes the average more
310310
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
312312
the magnitude of any potential scale.
313313
-->
314314
如果缺失某些度量值,控制平面会更保守地重新计算平均值,在需要缩小时假设这些 Pod 消耗了目标值的 100%,
@@ -325,7 +325,7 @@ of the desired metric, further dampening the magnitude of a scale up.
325325

326326
<!--
327327
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
329329
direction, or is within the tolerance, the controller doesn't take any scaling
330330
action. In other cases, the new ratio is used to decide any change to the
331331
number of Pods.
@@ -335,7 +335,7 @@ number of Pods.
335335
在其他情况下,新比率用于决定对 Pod 数量的任何更改。
336336

337337
<!--
338-
Note that the *original* value for the average utilization is reported
338+
Note that the _original_ value for the average utilization is reported
339339
back via the HorizontalPodAutoscaler status, without factoring in the
340340
not-yet-ready pods or missing metrics, even when the new usage ratio is
341341
used.
@@ -360,7 +360,7 @@ the current value.
360360
这表示,如果一个或多个指标给出的 `desiredReplicas` 值大于当前值,HPA 仍然能实现扩容。
361361

362362
<!--
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
364364
controller considers all recommendations within a configurable window choosing the
365365
highest recommendation from within that window. This value can be configured using the `--horizontal-pod-autoscaler-downscale-stabilization` flag, which defaults to 5 minutes.
366366
This means that scaledowns will occur gradually, smoothing out the impact of rapidly
@@ -377,7 +377,7 @@ fluctuating metric values.
377377
## API Object
378378
379379
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
381381
the `autoscaling/v2` API version which includes support for scaling on
382382
memory and custom metrics. The new fields introduced in
383383
`autoscaling/v2` are preserved as annotations when working with
@@ -405,8 +405,8 @@ More details about the API object can be found at
405405
406406
When managing the scale of a group of replicas using the HorizontalPodAutoscaler,
407407
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.
410410
-->
411411
## 工作量规模的稳定性 {#flapping}
412412

@@ -614,7 +614,7 @@ HorizontalPodAutoscaler 采用为每个指标推荐的最大比例,
614614
<!--
615615
## Support for metrics APIs
616616

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
618618
APIs, cluster administrators must ensure that:
619619
-->
620620
## 对 Metrics API 的支持 {#support-for-metrics-apis}
@@ -628,25 +628,25 @@ APIs, cluster administrators must ensure that:
628628
* The corresponding APIs are registered:
629629

630630
* 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.
632632

633633
* 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.
635635

636636
* For external metrics, this is the `external.metrics.k8s.io` API. It may be provided by the custom metrics adapters provided above.
637637
-->
638638
* 启用了 [API 聚合层](/zh-cn/docs/tasks/extend-kubernetes/configure-aggregation-layer/)
639639

640640
* 相应的 API 已注册:
641641

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) 提供。
643643
它可以作为集群插件启动。
644644

645-
* 对于自定义指标,将使用 `custom.metrics.k8s.io` API。
645+
* 对于自定义指标,将使用 `custom.metrics.k8s.io` API。
646646
它由其他度量指标方案厂商的“适配器(Adapter)” API 服务器提供。
647647
检查你的指标管道以查看是否有可用的 Kubernetes 指标适配器。
648648

649-
* 对于外部指标,将使用 `external.metrics.k8s.io` API。可能由上面的自定义指标适配器提供。
649+
* 对于外部指标,将使用 `external.metrics.k8s.io` API。可能由上面的自定义指标适配器提供。
650650

651651
<!--
652652
For more information on these different metrics paths and how they differ please see the relevant design proposals for
@@ -918,6 +918,7 @@ behavior:
918918
scaleDown:
919919
selectPolicy: Disabled
920920
```
921+
921922
<!--
922923
## Support for HorizontalPodAutoscaler in kubectl
923924

@@ -936,7 +937,7 @@ Finally, you can delete an autoscaler using `kubectl delete hpa`.
936937
<!--
937938
In addition, there is a special `kubectl autoscale` command for creating a HorizontalPodAutoscaler object.
938939
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%`
940941
and the number of replicas between 2 and 5.
941942
-->
942943
此外,还有一个特殊的 `kubectl autoscale` 命令用于创建 HorizontalPodAutoscaler 对象。
@@ -948,7 +949,7 @@ and the number of replicas between 2 and 5.
948949

949950
You can implicitly deactivate the HPA for a target without the
950951
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
952953
stops adjusting the target (and sets the `ScalingActive` Condition on itself
953954
to `false`) until you reactivate it by manually adjusting the target's desired
954955
replica count or HPA's minimum replica count.
@@ -965,7 +966,7 @@ replica count or HPA's minimum replica count.
965966

966967
When an HPA is enabled, it is recommended that the value of `spec.replicas` of
967968
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
969970
a change to that object is applied, for example via `kubectl apply -f
970971
deployment.yaml`, this will instruct Kubernetes to scale the current number of Pods
971972
to the value of the `spec.replicas` key. This may not be
@@ -984,9 +985,9 @@ Deployment 和/或 StatefulSet 的 `spec.replicas` 的值。
984985
Keep in mind that the removal of `spec.replicas` may incur a one-time
985986
degradation of Pod counts as the default value of this key is 1 (reference
986987
[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
988989
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
990991
methods based on how you are modifying your deployments:
991992
-->
992993
请记住,删除 `spec.replicas` 可能会导致 Pod 计数一次性降级,因为此键的默认值为 1
@@ -1000,10 +1001,10 @@ methods based on how you are modifying your deployments:
10001001
<!--
10011002
1. `kubectl apply edit-last-applied deployment/<deployment_name>`
10021003
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.
10041005
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.
10071008
4. From here on out you can run `kubectl apply -f deployment.yaml`
10081009
-->
10091010
1. `kubectl apply edit-last-applied deployment/<Deployment 名称>`
@@ -1053,4 +1054,3 @@ For more information on HorizontalPodAutoscaler:
10531054
* 如果你想编写自己的自定义指标适配器,
10541055
请查看 [boilerplate](https://github.com/kubernetes-sigs/custom-metrics-apiserver) 以开始使用。
10551056
* 阅读 [API 参考](/zh-cn/docs/reference/kubernetes-api/workload-resources/horizontal-pod-autoscaler-v2/)。
1056-

content/zh-cn/docs/tasks/run-application/run-single-instance-stateful-application.md

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ application is MySQL.
3636
<!--
3737
You can run a stateful application by creating a Kubernetes Deployment
3838
and connecting it to an existing PersistentVolume using a
39-
PersistentVolumeClaim. For example, this YAML file describes a
39+
PersistentVolumeClaim. For example, this YAML file describes a
4040
Deployment that runs MySQL and references the PersistentVolumeClaim. The file
4141
defines a volume mount for /var/lib/mysql, and then creates a
4242
PersistentVolumeClaim that looks for a 20G volume. This claim is
@@ -60,22 +60,28 @@ for a secure solution.
6060
{{< codenew file="application/mysql/mysql-deployment.yaml" >}}
6161
{{< codenew file="application/mysql/mysql-pv.yaml" >}}
6262

63-
1. <!--Deploy the PV and PVC of the YAML file-->
64-
部署 YAML 文件中定义的 PV 和 PVC:
63+
<!--
64+
1. Deploy the PV and PVC of the YAML file:
65+
-->
66+
1. 部署 YAML 文件中定义的 PV 和 PVC:
6567

6668
```shell
6769
kubectl apply -f https://k8s.io/examples/application/mysql/mysql-pv.yaml
6870
```
6971

70-
1. <!-- Deploy the contents of the YAML file -->
71-
部署 YAML 文件中定义的 Deployment:
72+
<!--
73+
1. Deploy the contents of the YAML file:
74+
-->
75+
2. 部署 YAML 文件中定义的 Deployment:
7276

7377
```shell
7478
kubectl apply -f https://k8s.io/examples/application/mysql/mysql-deployment.yaml
7579
```
7680

77-
1. <!-- Display information about the Deployment -->
78-
展示 Deployment 相关信息:
81+
<!--
82+
1. Display information about the Deployment:
83+
-->
84+
3. 展示 Deployment 相关信息:
7985

8086
```shell
8187
kubectl describe deployment mysql
@@ -111,21 +117,23 @@ for a secure solution.
111117
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
112118
ClaimName: mysql-pv-claim
113119
ReadOnly: false
114-
Conditions:
115-
Type Status Reason
116-
---- ------ ------
117-
Available False MinimumReplicasUnavailable
118-
Progressing True ReplicaSetUpdated
119-
OldReplicaSets: <none>
120-
NewReplicaSet: mysql-63082529 (1/1 replicas created)
121-
Events:
122-
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
123-
--------- -------- ----- ---- ------------- -------- ------ -------
124-
33s 33s 1 {deployment-controller } Normal ScalingReplicaSet Scaled up replica set mysql-63082529 to 1
120+
Conditions:
121+
Type Status Reason
122+
---- ------ ------
123+
Available False MinimumReplicasUnavailable
124+
Progressing True ReplicaSetUpdated
125+
OldReplicaSets: <none>
126+
NewReplicaSet: mysql-63082529 (1/1 replicas created)
127+
Events:
128+
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
129+
--------- -------- ----- ---- ------------- -------- ------ -------
130+
33s 33s 1 {deployment-controller } Normal ScalingReplicaSet Scaled up replica set mysql-63082529 to 1
125131
```
126132

127-
1. <!-- List the pods created by the Deployment -->
128-
列举出 Deployment 创建的 pods:
133+
<!--
134+
1. List the pods created by the Deployment:
135+
-->
136+
4. 列举出 Deployment 创建的 pods:
129137

130138
```shell
131139
kubectl get pods -l app=mysql
@@ -141,8 +149,10 @@ for a secure solution.
141149
mysql-63082529-2z3ki 1/1 Running 0 3m
142150
```
143151

144-
1. <!-- Inspect the PersistentVolumeClaim -->
145-
查看 PersistentVolumeClaim:
152+
<!--
153+
1. Inspect the PersistentVolumeClaim:
154+
-->
155+
5. 查看 PersistentVolumeClaim:
146156

147157
```shell
148158
kubectl describe pvc mysql-pv-claim
@@ -180,14 +190,13 @@ Run a MySQL client to connect to the server:
180190
-->
181191
## 访问 MySQL 实例 {#accessing-the-mysql-instance}
182192

183-
184193
前面 YAML 文件中创建了一个允许集群内其他 Pod 访问的数据库服务。该服务中选项
185194
`clusterIP: None` 让服务 DNS 名称直接解析为 Pod 的 IP 地址。
186195
当在一个服务下只有一个 Pod 并且不打算增加 Pod 的数量这是最好的.
187196

188197
运行 MySQL 客户端以连接到服务器:
189198

190-
```
199+
```shell
191200
kubectl run -it --rm --image=mysql:5.6 --restart=Never mysql-client -- mysql -h mysql -ppassword
192201
```
193202

@@ -246,7 +255,7 @@ Delete the deployed objects by name:
246255

247256
通过名称删除部署的对象:
248257

249-
```
258+
```shell
250259
kubectl delete deployment,svc mysql
251260
kubectl delete pvc mysql-pv-claim
252261
kubectl delete pv mysql-pv-volume
@@ -282,5 +291,3 @@ PersistentVolume 将被自动删除。
282291
* 参阅 [kubectl run 文档](/docs/reference/generated/kubectl/kubectl-commands/#run)
283292

284293
* 参阅[](/zh-cn/docs/concepts/storage/volumes/)[持久卷](/zh-cn/docs/concepts/storage/persistent-volumes/)
285-
286-

0 commit comments

Comments
 (0)