Skip to content

Commit 9409393

Browse files
committed
[zh] Relocate manage and update labels sections
1 parent 3296a1d commit 9409393

File tree

2 files changed

+141
-146
lines changed

2 files changed

+141
-146
lines changed

content/zh-cn/docs/concepts/cluster-administration/manage-deployment.md

Lines changed: 3 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,9 @@ weight: 40
1616
<!--
1717
You've deployed your application and exposed it via a service. Now what? Kubernetes provides a
1818
number of tools to help you manage your application deployment, including scaling and updating.
19-
Among the features that we will discuss in more depth are
20-
[configuration files](/docs/concepts/configuration/overview/) and
21-
[labels](/docs/concepts/overview/working-with-objects/labels/).
2219
-->
2320
你已经部署了应用并通过服务暴露它。然后呢?
2421
Kubernetes 提供了一些工具来帮助管理你的应用部署,包括扩缩容和更新。
25-
我们将更深入讨论的特性包括
26-
[配置文件](/zh-cn/docs/concepts/configuration/overview/)
27-
[标签](/zh-cn/docs/concepts/overview/working-with-objects/labels/)
2822

2923
<!-- body -->
3024

@@ -262,99 +256,19 @@ If you're interested in learning more about `kubectl`, go ahead and read
262256
如果你有兴趣进一步学习关于 `kubectl` 的内容,请阅读[命令行工具(kubectl)](/zh-cn/docs/reference/kubectl/)
263257

264258
<!--
265-
## Using labels effectively
266-
267-
The examples we've used so far apply at most a single label to any resource. There are many
268-
scenarios where multiple labels should be used to distinguish sets from one another.
269-
-->
270-
## 有效地使用标签 {#using-labels-effectively}
271-
272-
到目前为止我们使用的示例中的资源最多使用了一个标签。
273-
在许多情况下,应使用多个标签来区分集合。
274-
275-
<!--
276-
For instance, different applications would use different values for the `app` label, but a
277-
multi-tier application, such as the [guestbook example](https://github.com/kubernetes/examples/tree/master/guestbook/),
278-
would additionally need to distinguish each tier. The frontend could carry the following labels:
279-
-->
280-
例如,不同的应用可能会为 `app` 标签设置不同的值。
281-
但是,类似 [guestbook 示例](https://github.com/kubernetes/examples/tree/master/guestbook/)
282-
这样的多层应用,还需要区分每一层。前端可以带以下标签:
283-
284-
```yaml
285-
labels:
286-
app: guestbook
287-
tier: frontend
288-
```
289-
290-
<!--
291-
while the Redis master and slave would have different `tier` labels, and perhaps even an
292-
additional `role` label:
293-
-->
294-
Redis 的主节点和从节点会有不同的 `tier` 标签,甚至还有一个额外的 `role` 标签:
295-
296-
```yaml
297-
labels:
298-
app: guestbook
299-
tier: backend
300-
role: master
301-
```
302-
303-
<!--
304-
and
305-
-->
306-
以及
307-
308-
```yaml
309-
labels:
310-
app: guestbook
311-
tier: backend
312-
role: slave
313-
```
314-
315-
<!--
316-
The labels allow us to slice and dice our resources along any dimension specified by a label:
259+
## Canary deployments
317260
-->
318-
标签允许我们按照标签指定的任何维度对我们的资源进行切片和切块:
319-
320-
```shell
321-
kubectl apply -f examples/guestbook/all-in-one/guestbook-all-in-one.yaml
322-
kubectl get pods -Lapp -Ltier -Lrole
323-
```
324-
325-
```none
326-
NAME READY STATUS RESTARTS AGE APP TIER ROLE
327-
guestbook-fe-4nlpb 1/1 Running 0 1m guestbook frontend <none>
328-
guestbook-fe-ght6d 1/1 Running 0 1m guestbook frontend <none>
329-
guestbook-fe-jpy62 1/1 Running 0 1m guestbook frontend <none>
330-
guestbook-redis-master-5pg3b 1/1 Running 0 1m guestbook backend master
331-
guestbook-redis-slave-2q2yf 1/1 Running 0 1m guestbook backend slave
332-
guestbook-redis-slave-qgazl 1/1 Running 0 1m guestbook backend slave
333-
my-nginx-divi2 1/1 Running 0 29m nginx <none> <none>
334-
my-nginx-o0ef1 1/1 Running 0 29m nginx <none> <none>
335-
```
336-
337-
```shell
338-
kubectl get pods -lapp=guestbook,role=slave
339-
```
261+
## 金丝雀部署(Canary Deployments) {#canary-deployments}
340262

341-
```none
342-
NAME READY STATUS RESTARTS AGE
343-
guestbook-redis-slave-2q2yf 1/1 Running 0 3m
344-
guestbook-redis-slave-qgazl 1/1 Running 0 3m
345-
```
263+
<!--TODO: make a task out of this for canary deployment, ref #42786-->
346264

347265
<!--
348-
## Canary deployments
349-
350266
Another scenario where multiple labels are needed is to distinguish deployments of different
351267
releases or configurations of the same component. It is common practice to deploy a *canary* of a
352268
new application release (specified via image tag in the pod template) side by side with the
353269
previous release so that the new release can receive live production traffic before fully rolling
354270
it out.
355271
-->
356-
## 金丝雀部署(Canary Deployments) {#canary-deployments}
357-
358272
另一个需要多标签的场景是用来区分同一组件的不同版本或者不同配置的多个部署。
359273
常见的做法是部署一个使用*金丝雀发布*来部署新应用版本
360274
(在 Pod 模板中通过镜像标签指定),保持新旧版本应用同时运行。
@@ -432,61 +346,6 @@ For a more concrete example, check the
432346
想要了解更具体的示例,请查看
433347
[Ghost 部署教程](https://github.com/kelseyhightower/talks/tree/master/kubecon-eu-2016/demo#deploy-a-canary)。
434348

435-
<!--
436-
## Updating labels
437-
438-
Sometimes existing pods and other resources need to be relabeled before creating new resources.
439-
This can be done with `kubectl label`.
440-
For example, if you want to label all your nginx pods as frontend tier, run:
441-
-->
442-
## 更新标签 {#updating-labels}
443-
444-
有时,现有的 pod 和其它资源需要在创建新资源之前重新标记。
445-
这可以用 `kubectl label` 完成。
446-
例如,如果想要将所有 nginx pod 标记为前端层,运行:
447-
448-
```shell
449-
kubectl label pods -l app=nginx tier=fe
450-
```
451-
452-
```none
453-
pod/my-nginx-2035384211-j5fhi labeled
454-
pod/my-nginx-2035384211-u2c7e labeled
455-
pod/my-nginx-2035384211-u3t6x labeled
456-
```
457-
458-
<!--
459-
This first filters all pods with the label "app=nginx", and then labels them with the "tier=fe".
460-
To see the pods you labeled, run:
461-
-->
462-
首先用标签 "app=nginx" 过滤所有的 Pod,然后用 "tier=fe" 标记它们。
463-
想要查看你刚才标记的 Pod,请运行:
464-
465-
```shell
466-
kubectl get pods -l app=nginx -L tier
467-
```
468-
469-
```none
470-
NAME READY STATUS RESTARTS AGE TIER
471-
my-nginx-2035384211-j5fhi 1/1 Running 0 23m fe
472-
my-nginx-2035384211-u2c7e 1/1 Running 0 23m fe
473-
my-nginx-2035384211-u3t6x 1/1 Running 0 23m fe
474-
```
475-
476-
<!--
477-
This outputs all "app=nginx" pods, with an additional label column of pods' tier (specified with
478-
`-L` or `--label-columns`).
479-
480-
For more information, please see [labels](/docs/concepts/overview/working-with-objects/labels/)
481-
and [kubectl label](/docs/reference/generated/kubectl/kubectl-commands/#label).
482-
-->
483-
这将输出所有 "app=nginx" 的 Pod,并有一个额外的描述 Pod 的 tier 的标签列
484-
(用参数 `-L` 或者 `--label-columns` 标明)。
485-
486-
想要了解更多信息,请参考[标签](/zh-cn/docs/concepts/overview/working-with-objects/labels/)和
487-
[`kubectl label`](/docs/reference/generated/kubectl/kubectl-commands/#label)
488-
命令文档。
489-
490349
<!--
491350
## Updating annotations
492351

content/zh-cn/docs/concepts/overview/working-with-objects/labels.md

Lines changed: 138 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,19 +495,155 @@ a pod can schedule. See the documentation on
495495
通过标签进行选择的一个用例是确定节点集,方便 Pod 调度。
496496
有关更多信息,请参阅[选择节点](/zh-cn/docs/concepts/scheduling-eviction/assign-pod-node/)文档。
497497

498+
<!--
499+
## Using labels effectively
500+
501+
The examples we've used so far apply at most a single label to any resource. There are many
502+
scenarios where multiple labels should be used to distinguish sets from one another.
503+
-->
504+
## 有效地使用标签 {#using-labels-effectively}
505+
506+
到目前为止我们使用的示例中的资源最多使用了一个标签。
507+
在许多情况下,应使用多个标签来区分不同集合。
508+
509+
<!--
510+
For instance, different applications would use different values for the `app` label, but a
511+
multi-tier application, such as the [guestbook example](https://github.com/kubernetes/examples/tree/master/guestbook/),
512+
would additionally need to distinguish each tier. The frontend could carry the following labels:
513+
-->
514+
例如,不同的应用可能会为 `app` 标签设置不同的值。
515+
但是,类似 [guestbook 示例](https://github.com/kubernetes/examples/tree/master/guestbook/)
516+
这样的多层应用,还需要区分每一层。前端可能会带有以下标签:
517+
518+
```yaml
519+
labels:
520+
app: guestbook
521+
tier: frontend
522+
```
523+
524+
<!--
525+
while the Redis master and replica would have different `tier` labels, and perhaps even an
526+
additional `role` label:
527+
-->
528+
Redis 的主从节点会有不同的 `tier` 标签,甚至还有一个额外的 `role` 标签:
529+
530+
```yaml
531+
labels:
532+
app: guestbook
533+
tier: backend
534+
role: master
535+
```
536+
537+
<!--
538+
and
539+
-->
540+
以及
541+
542+
```yaml
543+
labels:
544+
app: guestbook
545+
tier: backend
546+
role: replica
547+
```
548+
549+
<!--
550+
The labels allow us to slice and dice our resources along any dimension specified by a label:
551+
-->
552+
标签使得我们能够按照所指定的任何维度对我们的资源进行切片和切块:
553+
554+
```shell
555+
kubectl apply -f examples/guestbook/all-in-one/guestbook-all-in-one.yaml
556+
kubectl get pods -Lapp -Ltier -Lrole
557+
```
558+
559+
```none
560+
NAME READY STATUS RESTARTS AGE APP TIER ROLE
561+
guestbook-fe-4nlpb 1/1 Running 0 1m guestbook frontend <none>
562+
guestbook-fe-ght6d 1/1 Running 0 1m guestbook frontend <none>
563+
guestbook-fe-jpy62 1/1 Running 0 1m guestbook frontend <none>
564+
guestbook-redis-master-5pg3b 1/1 Running 0 1m guestbook backend master
565+
guestbook-redis-replica-2q2yf 1/1 Running 0 1m guestbook backend replica
566+
guestbook-redis-replica-qgazl 1/1 Running 0 1m guestbook backend replica
567+
my-nginx-divi2 1/1 Running 0 29m nginx <none> <none>
568+
my-nginx-o0ef1 1/1 Running 0 29m nginx <none> <none>
569+
```
570+
571+
```shell
572+
kubectl get pods -lapp=guestbook,role=replica
573+
```
574+
575+
```none
576+
NAME READY STATUS RESTARTS AGE
577+
guestbook-redis-replica-2q2yf 1/1 Running 0 3m
578+
guestbook-redis-replica-qgazl 1/1 Running 0 3m
579+
```
580+
581+
<!--
582+
## Updating labels
583+
584+
Sometimes existing pods and other resources need to be relabeled before creating new resources.
585+
This can be done with `kubectl label`.
586+
For example, if you want to label all your nginx pods as frontend tier, run:
587+
-->
588+
## 更新标签 {#updating-labels}
589+
590+
有时需要要在创建新资源之前对现有的 Pod 和其它资源重新打标签。
591+
这可以用 `kubectl label` 完成。
592+
例如,如果想要将所有 NGINX Pod 标记为前端层,运行:
593+
594+
```shell
595+
kubectl label pods -l app=nginx tier=fe
596+
```
597+
598+
```none
599+
pod/my-nginx-2035384211-j5fhi labeled
600+
pod/my-nginx-2035384211-u2c7e labeled
601+
pod/my-nginx-2035384211-u3t6x labeled
602+
```
603+
604+
<!--
605+
This first filters all pods with the label "app=nginx", and then labels them with the "tier=fe".
606+
To see the pods you labeled, run:
607+
-->
608+
首先用标签 "app=nginx" 过滤所有的 Pod,然后用 "tier=fe" 标记它们。
609+
想要查看你刚设置了标签的 Pod,请运行:
610+
611+
```shell
612+
kubectl get pods -l app=nginx -L tier
613+
```
614+
615+
```none
616+
NAME READY STATUS RESTARTS AGE TIER
617+
my-nginx-2035384211-j5fhi 1/1 Running 0 23m fe
618+
my-nginx-2035384211-u2c7e 1/1 Running 0 23m fe
619+
my-nginx-2035384211-u3t6x 1/1 Running 0 23m fe
620+
```
621+
622+
<!--
623+
This outputs all "app=nginx" pods, with an additional label column of pods' tier (specified with
624+
`-L` or `--label-columns`).
625+
626+
For more information, please see [labels](/docs/concepts/overview/working-with-objects/labels/)
627+
and [kubectl label](/docs/reference/generated/kubectl/kubectl-commands/#label).
628+
-->
629+
此命令将输出所有 "app=nginx" 的 Pod,并有一个额外的描述 Pod 所在分层的标签列
630+
(用参数 `-L` 或者 `--label-columns` 标明)。
631+
632+
想要了解更多信息,请参考[标签](/zh-cn/docs/concepts/overview/working-with-objects/labels/)和
633+
[`kubectl label`](/docs/reference/generated/kubectl/kubectl-commands/#label)
634+
命令文档。
635+
498636
## {{% heading "whatsnext" %}}
499637

500638
<!--
501639
- Learn how to [add a label to a node](/docs/tasks/configure-pod-container/assign-pods-nodes/#add-a-label-to-a-node)
502640
- Find [Well-known labels, Annotations and Taints](/docs/reference/labels-annotations-taints/)
503641
- See [Recommended labels](/docs/concepts/overview/working-with-objects/common-labels/)
504642
- [Enforce Pod Security Standards with Namespace Labels](/docs/tasks/configure-pod-container/enforce-standards-namespace-labels/)
505-
- [Use Labels effectively](/docs/concepts/cluster-administration/manage-deployment/#using-labels-effectively) to manage deployments.
506643
- Read a blog on [Writing a Controller for Pod Labels](/blog/2021/06/21/writing-a-controller-for-pod-labels/)
507644
-->
508645
- 学习如何[给节点添加标签](/zh-cn/docs/tasks/configure-pod-container/assign-pods-nodes/#add-a-label-to-a-node)
509646
- 查阅[众所周知的标签、注解和污点](/zh-cn/docs/reference/labels-annotations-taints/)
510647
- 参见[推荐使用的标签](/zh-cn/docs/concepts/overview/working-with-objects/common-labels/)
511648
- [使用名字空间标签来实施 Pod 安全性标准](/zh-cn/docs/tasks/configure-pod-container/enforce-standards-namespace-labels/)
512-
- [有效使用标签](/zh-cn/docs/concepts/cluster-administration/manage-deployment/#using-labels-effectively)管理 Deployment。
513649
- 阅读[为 Pod 标签编写控制器](/blog/2021/06/21/writing-a-controller-for-pod-labels/)的博文

0 commit comments

Comments
 (0)