@@ -12,6 +12,7 @@ title: kubeadm init
12
12
content_type: concept
13
13
weight: 20
14
14
-->
15
+
15
16
<!-- overview -->
16
17
17
18
<!--
@@ -148,7 +149,7 @@ following steps:
148
149
149
150
Kubeadm allows you to create a control-plane node in phases using the `kubeadm init phase` command.
150
151
-->
151
- ### 在 kubeadm 中使用 init phases {#init-phases}
152
+ ### 在 kubeadm 中使用 init 阶段 {#init-phases}
152
153
153
154
Kubeadm 允许你使用 ` kubeadm init phase ` 命令分阶段创建控制平面节点。
154
155
@@ -219,10 +220,10 @@ Alternatively, you can use the `skipPhases` field under `InitConfiguration`.
219
220
-->
220
221
### 结合一份配置文件来使用 kubeadm init {#config-file}
221
222
223
+ {{< caution >}}
222
224
<!--
223
225
The config file is still considered beta and may change in future versions.
224
226
-->
225
- {{< caution >}}
226
227
配置文件的功能仍然处于 alpha 状态并且在将来的版本中可能会改变。
227
228
{{< /caution >}}
228
229
@@ -294,19 +295,19 @@ List of feature gates:
294
295
-->
295
296
特性门控的列表:
296
297
297
- {{< table caption="kubeadm feature gates " >}}
298
+ {{< table caption="kubeadm 特性门控 " >}}
298
299
特性 | 默认值 | Alpha | Beta
299
300
:-------|:--------|:------|:-----
300
301
` PublicKeysECDSA ` | ` false ` | 1.19 | -
301
302
` RootlessControlPlane ` | ` false ` | 1.22 | -
302
303
` UnversionedKubeletConfigMap ` | ` true ` | 1.22 | 1.23
303
304
{{< /table >}}
304
305
306
+ {{< note >}}
305
307
<!--
306
308
Once a feature gate goes GA it is removed from this list as its value becomes locked to `true` by default.
307
309
-->
308
- {{< note >}}
309
- 一旦特性门控变成了 GA,那它将会从这个列表中移除,因为它的值会被默认锁定为 ` true ` 。
310
+ 一旦特性门控变成了 GA,那它将会从这个列表中移除,因为它的值会被默认锁定为 ` true ` 。
310
311
{{< /note >}}
311
312
312
313
<!--
@@ -367,21 +368,18 @@ Setting `UnversionedKubeletConfigMap` to `false` is supported but **deprecated**
367
368
设置 ` UnversionedKubeletConfigMap ` 为 ` false ` 是被支持的特性,但该特性** 已被弃用** 。
368
369
{{< /note >}}
369
370
370
-
371
-
372
-
373
371
<!--
374
372
### Adding kube-proxy parameters {#kube-proxy}
375
- -->
376
- ### 添加 kube-proxy 参数 {#kube-proxy}
377
373
378
- <!--
374
+
379
375
For information about kube-proxy parameters in the kubeadm configuration see:
380
376
- [kube-proxy reference](/docs/reference/config-api/kube-proxy-config.v1alpha1/)
381
377
382
378
For information about enabling IPVS mode with kubeadm see:
383
379
- [IPVS](https://github.com/kubernetes/kubernetes/blob/master/pkg/proxy/ipvs/README.md)
384
380
-->
381
+ ### 添加 kube-proxy 参数 {#kube-proxy}
382
+
385
383
kubeadm 配置中有关 kube-proxy 的说明请查看:
386
384
387
385
- [ kube-proxy 参考] ( /zh-cn/docs/reference/config-api/kube-proxy-config.v1alpha1/ )
@@ -392,28 +390,27 @@ kubeadm 配置中有关 kube-proxy 的说明请查看:
392
390
393
391
<!--
394
392
### Passing custom flags to control plane components {#control-plane-flags}
393
+
394
+ For information about passing flags to control plane components see:
395
+ - [control-plane-flags](/docs/setup/production-environment/tools/kubeadm/control-plane-flags/)
395
396
-->
396
397
### 向控制平面组件传递自定义的命令行参数 {#control-plane-flags}
397
398
398
- <!--
399
- For information about passing flags to control plane components see:
400
- - [control-plane-flags](/docs/setup/production-environment/tools/kubeadm/control-plane-flags/) -->
401
399
有关向控制平面组件传递命令行参数的说明请查看:
402
- [ 控制平面命令行参数] ( /zh-cn/docs/setup/production-environment/tools/kubeadm/control-plane-flags/ )
400
+
401
+ - [ 控制平面命令行参数] ( /zh-cn/docs/setup/production-environment/tools/kubeadm/control-plane-flags/ )
403
402
404
403
<!--
405
404
### Running kubeadm without an Internet connection {#without-internet-connection}
406
- -->
407
- ### 在没有互联网连接的情况下运行 kubeadm {#without-internet-connection}
408
405
409
- <!--
410
406
For running kubeadm without an internet connection you have to pre-pull the required control-plane images.
411
- -->
412
- 要在没有互联网连接的情况下运行 kubeadm,你必须提前拉取所需的控制平面镜像。
413
407
414
- <!--
415
408
You can list and pull the images using the `kubeadm config images` sub-command:
416
409
-->
410
+ ### 在没有互联网连接的情况下运行 kubeadm {#without-internet-connection}
411
+
412
+ 要在没有互联网连接的情况下运行 kubeadm,你必须提前拉取所需的控制平面镜像。
413
+
417
414
你可以使用 ` kubeadm config images ` 子命令列出并拉取镜像:
418
415
419
416
``` shell
@@ -425,7 +422,8 @@ kubeadm config images pull
425
422
You can pass `--config` to the above commands with a [kubeadm configuration file](#config-file)
426
423
to control the `kubernetesVersion` and `imageRepository` fields.
427
424
-->
428
- 你可以通过 ` --config ` 把 [ kubeadm 配置文件] ( #config-file ) 传递给上述命令来控制 ` kubernetesVersion ` 和 ` imageRepository ` 字段。
425
+ 你可以通过 ` --config ` 把 [ kubeadm 配置文件] ( #config-file ) 传递给上述命令来控制
426
+ ` kubernetesVersion ` 和 ` imageRepository ` 字段。
429
427
430
428
<!--
431
429
All default `k8s.gcr.io` images that kubeadm requires support multiple architectures.
@@ -434,43 +432,41 @@ kubeadm 需要的所有默认 `k8s.gcr.io` 镜像都支持多种硬件体系结
434
432
435
433
<!--
436
434
### Using custom images {#custom-images}
437
- -->
438
- ### 使用自定义的镜像 {#custom-images}
439
435
440
- <!--
441
436
By default, kubeadm pulls images from `k8s.gcr.io`. If the
442
437
requested Kubernetes version is a CI label (such as `ci/latest`)
443
438
`gcr.io/k8s-staging-ci-images` is used.
444
439
-->
445
- 默认情况下, kubeadm 会从 ` k8s.gcr.io ` 仓库拉取镜像。如果请求的 Kubernetes 版本是 CI 标签
440
+ ### 使用自定义的镜像 {#custom-images}
441
+
442
+ 默认情况下,kubeadm 会从 ` k8s.gcr.io ` 仓库拉取镜像。如果请求的 Kubernetes 版本是 CI 标签
446
443
(例如 ` ci/latest ` ),则使用 ` gcr.io/k8s-staging-ci-images ` 。
447
444
448
445
<!--
449
446
You can override this behavior by using [kubeadm with a configuration file](#config-file).
450
- -->
451
- 你可以通过使用[ 带有配置文件的 kubeadm] ( #config-file ) 来重写此操作。
452
-
453
- <!--
454
447
Allowed customization are:
455
448
456
449
* To provide `kubernetesVersion` which affects the version of the images.
457
450
* To provide an alternative `imageRepository` to be used instead of
458
451
`k8s.gcr.io`.
459
452
* To provide a specific `imageRepository` and `imageTag` for etcd or CoreDNS.
453
+
460
454
-->
455
+ 你可以通过使用[ 带有配置文件的 kubeadm] ( #config-file ) 来重写此操作。
461
456
允许的自定义功能有:
462
457
463
458
* 提供影响镜像版本的 ` kubernetesVersion ` 。
464
459
* 使用其他的 ` imageRepository ` 来代替 ` k8s.gcr.io ` 。
465
460
* 为 etcd 或 CoreDNS 提供特定的 ` imageRepository ` 和 ` imageTag ` 。
466
461
467
462
<!--
463
+ Image paths between the default `k8s.gcr.io` and a custom repository specified using
468
464
`imageRepository` may differ for backwards compatibility reasons. For example,
469
465
one image might have a subpath at `k8s.gcr.io/subpath/image`, but be defaulted
470
- to `my.customrepository.io/image` when using a custom repository.
466
+ to `my.customrepository.io/image` when using a custom repository.
471
467
-->
472
- 由于向后兼容的原因,` imageRepository ` 可能会有所不同。
473
- 例如,某镜像的子路径可能是 ` k8s.gcr.io/subpath/image ` ,
468
+ 由于向后兼容的原因,使用 ` imageRepository ` 所指定的定制镜像库可能与默认的
469
+ ` k8s.gcr.io ` 镜像路径不同。 例如,某镜像的子路径可能是 ` k8s.gcr.io/subpath/image ` ,
474
470
但使用自定义仓库时默认为 ` my.customrepository.io/image ` 。
475
471
476
472
<!--
@@ -488,23 +484,39 @@ for etcd and CoreDNS.
488
484
-->
489
485
* 使用 ` kubeadm config images {list|pull} ` 从 ` k8s.gcr.io ` 的默认路径中拉取镜像。
490
486
* 将镜像推送到 ` kubeadm config images list --config=config.yaml ` 的路径,
491
- 其中 ` config.yaml ` 包含自定义的 ` imageRepository ` 和/或用于 etcd 和 CoreDNS 的 ` imageTag ` 。
487
+ 其中 ` config.yaml ` 包含自定义的 ` imageRepository ` 和/或用于 etcd 和 CoreDNS 的 ` imageTag ` 。
492
488
* 将相同的 ` config.yaml ` 传递给 ` kubeadm init ` 。
493
489
494
-
495
490
<!--
496
- ### Uploading control-plane certificates to the cluster
491
+ #### Custom sandbox (pause) images {#custom-pause-image}
492
+
493
+ To set a custom image for these you need to configure this in your
494
+ {{< glossary_tooltip text="container runtime" term_id="container-runtime" >}}
495
+ to use the image.
496
+ Consult the documentation for your container runtime to find out how to change this setting;
497
+ for selected container runtimes, you can also find advice within the
498
+ [Container Runtimes]((/docs/setup/production-environment/container-runtimes/) topic.
497
499
-->
498
- ### 将控制平面证书上传到集群
500
+ #### 定制沙箱(pause)镜像 {#custom-pause-image}
501
+
502
+ 如果需要为这些组件设置定制的镜像,你需要在你的{{< glossary_tooltip text="容器运行时" term_id="container-runtime" >}}
503
+ 中完成一些配置。参阅你的容器运行时的文档以了解如何改变此设置。
504
+ 对于某些容器运行时而言,
505
+ 你可以在[ 容器运行时] ( /zh-cn/docs/setup/production-environment/container-runtimes/ )
506
+ 主题下找到一些建议。
499
507
500
508
<!--
509
+ ### Uploading control-plane certificates to the cluster
510
+
501
511
By adding the flag `-upload-certs` to `kubeadm init` you can temporary upload
502
512
the control-plane certificates to a Secret in the cluster. Please note that this Secret
503
513
will expire automatically after 2 hours. The certificates are encrypted using
504
514
a 32byte key that can be specified using `-certificate-key`. The same key can be used
505
515
to download the certificates when additional control-plane nodes are joining, by passing
506
516
`-control-plane` and `-certificate-key` to `kubeadm join`.
507
517
-->
518
+ ### 将控制平面证书上传到集群 {#uploading-control-plane-certificates-to-the-cluster}
519
+
508
520
通过将参数 ` --upload-certs ` 添加到 ` kubeadm init ` ,你可以将控制平面证书临时上传到集群中的 Secret。
509
521
请注意,此 Secret 将在 2 小时后自动过期。证书使用 32 字节密钥加密,可以使用 ` --certificate-key ` 指定。
510
522
通过将 ` --control-plane ` 和 ` --certificate-key ` 传递给 ` kubeadm join ` ,
@@ -522,100 +534,101 @@ kubeadm init phase upload-certs --upload-certs --certificate-key=SOME_VALUE --co
522
534
<!--
523
535
If the flag `-certificate-key` is not passed to `kubeadm init` and
524
536
`kubeadm init phase upload-certs` a new key will be generated automatically.
537
+
538
+ The following command can be used to generate a new key on demand:
525
539
-->
526
540
如果未将参数 ` --certificate-key ` 传递给 ` kubeadm init ` 和 ` kubeadm init phase upload-certs ` ,
527
541
则会自动生成一个新密钥。
528
542
529
- <!--
530
- The following command can be used to generate a new key on demand:
531
- -->
532
543
以下命令可用于按需生成新密钥:
533
544
534
545
``` shell
535
546
kubeadm certs certificate-key
536
547
```
537
548
538
- <!-- ### Certificate management with kubeadm -->
539
- ### 使用 kubeadm 管理证书
549
+ <!--
550
+ ### Certificate management with kubeadm
540
551
541
- <!--
542
552
For detailed information on certificate management with kubeadm see
543
553
[Certificate Management with kubeadm](/docs/tasks/administer-cluster/kubeadm/kubeadm-certs/).
544
554
The document includes information about using external CA, custom certificates
545
555
and certificate renewal.
546
556
-->
547
- 有关使用 kubeadm 进行证书管理的详细信息,请参阅
548
- [ 使用 kubeadm 进行证书管理] ( /zh-cn/docs/tasks/administer-cluster/kubeadm/kubeadm-certs/ ) 。
557
+ ### 使用 kubeadm 管理证书 {#certificate-management-with-kubeadm}
558
+
559
+ 有关使用 kubeadm 进行证书管理的详细信息,
560
+ 请参阅[ 使用 kubeadm 进行证书管理] ( /zh-cn/docs/tasks/administer-cluster/kubeadm/kubeadm-certs/ ) 。
549
561
该文档包括有关使用外部 CA,自定义证书和证书更新的信息。
550
562
551
563
<!--
552
564
### Managing the kubeadm drop-in file for the kubelet {#kubelet-drop-in}
553
- -->
554
- ### 管理 kubeadm 为 kubelet 提供的 systemd 配置文件 {#kubelet-drop-in}
555
565
556
- <!--
557
566
The `kubeadm` package ships with a configuration file for running the `kubelet` by `systemd`. Note that the kubeadm CLI never touches this drop-in file. This drop-in file is part of the kubeadm DEB/RPM package.
558
567
-->
568
+ ### 管理 kubeadm 为 kubelet 提供的 systemd 配置文件 {#kubelet-drop-in}
569
+
559
570
` kubeadm ` 包自带了关于 ` systemd ` 如何运行 ` kubelet ` 的配置文件。
560
571
请注意 ` kubeadm ` 客户端命令行工具永远不会修改这份 ` systemd ` 配置文件。
561
572
这份 ` systemd ` 配置文件属于 kubeadm DEB/RPM 包。
562
573
563
574
<!--
564
575
For further information, see [Managing the kubeadm drop-in file for systemd](/docs/setup/production-environment/tools/kubeadm/kubelet-integration/#the-kubelet-drop-in-file-for-systemd).
565
576
-->
566
- 有关更多信息,请阅读
567
- [ 管理 systemd 的 kubeadm 内嵌文件] ( /zh-cn/docs/setup/production-environment/tools/kubeadm/kubelet-integration/#the-kubelet-drop-in-file-for-systemd ) 。
577
+ 有关更多信息,请阅读[ 管理 systemd 的 kubeadm 内嵌文件] ( /zh-cn/docs/setup/production-environment/tools/kubeadm/kubelet-integration/#the-kubelet-drop-in-file-for-systemd ) 。
568
578
569
579
<!--
570
580
### Use kubeadm with CRI runtimes
571
- -->
572
- ### 结合 CRI 运行时使用 kubeadm
573
581
574
- <!--
575
582
By default kubeadm attempts to detect your container runtime. For more details on this detection, see
576
583
the [kubeadm CRI installation guide](/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#installing-runtime).
577
584
-->
585
+ ### 结合 CRI 运行时使用 kubeadm {#use-kubeadm-with-cri-runtimes}
586
+
578
587
默认情况下,kubeadm 尝试检测你的容器运行环境。有关此检测的更多详细信息,请参见
579
588
[ kubeadm CRI 安装指南] ( /zh-cn/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#installing-runtime ) 。
580
589
581
590
<!--
582
591
### Setting the node name
583
- -->
584
- ### 设置节点的名称
585
592
586
- <!--
587
593
By default, `kubeadm` assigns a node name based on a machine's host address. You can override this setting with the `-node-name` flag.
588
594
The flag passes the appropriate [`-hostname-override`](/docs/reference/command-line-tools-reference/kubelet/#options)
589
595
value to the kubelet.
590
596
-->
591
- 默认情况下, ` kubeadm ` 基于机器的主机地址分配一个节点名称。你可以使用 ` --node-name ` 参数覆盖此设置。
592
- 此标识将合适的
593
- [ ` --hostname-override ` ] ( /zh-cn/docs/reference/command-line-tools-reference/kubelet/#options )
597
+ ### 设置节点的名称 {#setting-the-node-name}
598
+
599
+ 默认情况下,` kubeadm ` 基于机器的主机地址分配一个节点名称。你可以使用 ` --node-name ` 参数覆盖此设置。
600
+ 此标识将合适的 [ ` --hostname-override ` ] ( /zh-cn/docs/reference/command-line-tools-reference/kubelet/#options )
594
601
值传递给 kubelet。
595
602
596
603
<!--
597
- ### Automating kubeadm
604
+ Be aware that overriding the hostname can [interfere with cloud providers](https://github.com/kubernetes/website/pull/8873).
598
605
-->
599
- ### kubeadm 自动化
606
+ 要注意,重载主机名可能会 [ 与云驱动发生冲突 ] ( https://github.com/kubernetes/website/pull/8873 ) 。
600
607
601
608
<!--
609
+ ### Automating kubeadm
610
+
602
611
Rather than copying the token you obtained from `kubeadm init` to each node, as
603
612
in the [basic kubeadm tutorial](/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/), you can parallelize the
604
613
token distribution for easier automation. To implement this automation, you must
605
614
know the IP address that the control-plane node will have after it is started,
606
615
or use a DNS name or an address of a load balancer.
607
616
-->
617
+ ### kubeadm 自动化 {#automating-kubeadm}
618
+
608
619
除了像文档 [ kubeadm 基础教程] ( /zh-cn/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/ )
609
620
中所描述的那样,将从 ` kubeadm init ` 取得的令牌复制到每个节点,
610
621
你还可以并行地分发令牌以实现简单自动化。
611
622
要实现自动化,你必须知道控制平面节点启动后将拥有的 IP 地址,或使用 DNS 名称或负载均衡器的地址。
612
623
613
624
<!--
614
- 1. Generate a token. This token must have the form `<6 character string>.<16
615
- character string>`. More formally, it must match the regex: `[a-z0-9]{6}\.[a-z0-9]{16}`.
616
- kubeadm can generate a token for you:
625
+ 1. Generate a token. This token must have the form `<6 character string>.<16
626
+ character string>`. More formally, it must match the regex:
627
+ `[a-z0-9]{6}\.[a-z0-9]{16}`.
628
+
629
+ kubeadm can generate a token for you:
617
630
-->
618
- 1 . 生成一个令牌。这个令牌必须具有以下格式:` < 6 个字符的字符串>.< 16 个字符的字符串> ` 。
631
+ 1 . 生成一个令牌。这个令牌必须具有以下格式:` <6 个字符的字符串>.<16 个字符的字符串> ` 。
619
632
更加正式的说法是,它必须符合以下正则表达式:` [a-z0-9]{6}\.[a-z0-9]{16} ` 。
620
633
621
634
kubeadm 可以为你生成一个令牌:
@@ -625,14 +638,16 @@ kubeadm can generate a token for you:
625
638
```
626
639
627
640
<!--
628
- 2. Start both the control-plane node and the worker nodes concurrently with this token.
629
- As they come up they should find each other and form the cluster. The same `-token` argument can be used on both `kubeadm init` and `kubeadm join`.
641
+ 1. Start both the control-plane node and the worker nodes concurrently with this token.
642
+ As they come up they should find each other and form the cluster. The same
643
+ `-token` argument can be used on both `kubeadm init` and `kubeadm join`.
630
644
-->
631
645
2 . 使用这个令牌同时启动控制平面节点和工作节点。它们一旦运行起来应该就会互相寻找对方并且建立集群。
632
646
同样的 ` --token ` 参数可以同时用于 ` kubeadm init ` 和 ` kubeadm join ` 命令。
633
647
634
648
<!--
635
- 3. Similar can be done for `-certificate-key` when joining additional control-plane nodes. The key can be generated using:
649
+ 1. Similar can be done for `-certificate-key` when joining additional control-plane
650
+ nodes. The key can be generated using:
636
651
-->
637
652
3 . 当加入其他控制平面节点时,可以对 ` --certificate-key ` 执行类似的操作。可以使用以下方式生成密钥:
638
653
@@ -653,8 +668,9 @@ it does not allow the root CA hash to be validated with
653
668
`-discovery-token-ca-cert-hash` (since it's not generated when the nodes are
654
669
provisioned). For details, see the [kubeadm join](/docs/reference/setup-tools/kubeadm/kubeadm-join/).
655
670
-->
656
- 注意这种搭建集群的方式在安全保证上会有一些宽松,因为这种方式不允许使用 ` --discovery-token-ca-cert-hash `
657
- 来验证根 CA 的哈希值(因为当配置节点的时候,它还没有被生成)。
671
+ 注意这种搭建集群的方式在安全保证上会有一些宽松,因为这种方式不允许使用
672
+ ` --discovery-token-ca-cert-hash ` 来验证根 CA 的哈希值
673
+ (因为当配置节点的时候,它还没有被生成)。
658
674
更多信息请参阅 [ kubeadm join] ( /zh-cn/docs/reference/setup-tools/kubeadm/kubeadm-join/ ) 文档。
659
675
660
676
## {{% heading "whatsnext" %}}
@@ -666,7 +682,7 @@ provisioned). For details, see the [kubeadm join](/docs/reference/setup-tools/ku
666
682
* [kubeadm upgrade](/docs/reference/setup-tools/kubeadm/kubeadm-upgrade/) to upgrade a Kubernetes cluster to a newer version
667
683
* [kubeadm reset](/docs/reference/setup-tools/kubeadm/kubeadm-reset/) to revert any changes made to this host by `kubeadm init` or `kubeadm join`
668
684
-->
669
- * 进一步阅读了解 [ kubeadm init phase ] ( /zh-cn/docs/reference/setup-tools/kubeadm/kubeadm-init-phase/ )
685
+ * 进一步阅读了解 [ kubeadm init 阶段 ] ( /zh-cn/docs/reference/setup-tools/kubeadm/kubeadm-init-phase/ )
670
686
* [ kubeadm join] ( /zh-cn/docs/reference/setup-tools/kubeadm/kubeadm-join/ )
671
687
启动一个 Kubernetes 工作节点并且将其加入到集群
672
688
* [ kubeadm upgrade] ( /zh-cn/docs/reference/setup-tools/kubeadm/kubeadm-upgrade/ )
0 commit comments