@@ -16,15 +16,9 @@ weight: 40
16
16
<!--
17
17
You've deployed your application and exposed it via a service. Now what? Kubernetes provides a
18
18
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/).
22
19
-->
23
20
你已经部署了应用并通过服务暴露它。然后呢?
24
21
Kubernetes 提供了一些工具来帮助管理你的应用部署,包括扩缩容和更新。
25
- 我们将更深入讨论的特性包括
26
- [ 配置文件] ( /zh-cn/docs/concepts/configuration/overview/ ) 和
27
- [ 标签] ( /zh-cn/docs/concepts/overview/working-with-objects/labels/ ) 。
28
22
29
23
<!-- body -->
30
24
@@ -262,99 +256,19 @@ If you're interested in learning more about `kubectl`, go ahead and read
262
256
如果你有兴趣进一步学习关于 ` kubectl ` 的内容,请阅读[ 命令行工具(kubectl)] ( /zh-cn/docs/reference/kubectl/ ) 。
263
257
264
258
<!--
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
317
260
-->
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}
340
262
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-->
346
264
347
265
<!--
348
- # # Canary deployments
349
-
350
266
Another scenario where multiple labels are needed is to distinguish deployments of different
351
267
releases or configurations of the same component. It is common practice to deploy a *canary* of a
352
268
new application release (specified via image tag in the pod template) side by side with the
353
269
previous release so that the new release can receive live production traffic before fully rolling
354
270
it out.
355
271
-->
356
- # # 金丝雀部署(Canary Deployments) {#canary-deployments}
357
-
358
272
另一个需要多标签的场景是用来区分同一组件的不同版本或者不同配置的多个部署。
359
273
常见的做法是部署一个使用* 金丝雀发布* 来部署新应用版本
360
274
(在 Pod 模板中通过镜像标签指定),保持新旧版本应用同时运行。
@@ -432,61 +346,6 @@ For a more concrete example, check the
432
346
想要了解更具体的示例,请查看
433
347
[Ghost 部署教程](https://github.com/kelseyhightower/talks/tree/master/kubecon-eu-2016/demo#deploy-a-canary)。
434
348
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
-
490
349
<!--
491
350
# # Updating annotations
492
351
0 commit comments