[zh] Remove reviewer for kubelet-integration.md

This commit is contained in:
Sean Wei
2022-05-26 16:46:00 +08:00
parent b05bcc9823
commit 91139fba44
@@ -1,6 +1,4 @@
---
reviewers:
- sig-cluster-lifecycle
title: 使用 kubeadm 配置集群中的每个 kubelet
content_type: concept
weight: 80
@@ -17,7 +15,7 @@ weight: 80
{{% dockershim-removal %}}
{{< feature-state for_k8s_version="1.11" state="stable" >}}
{{< feature-state for_k8s_version="v1.11" state="stable" >}}
<!--
The lifecycle of the kubeadm CLI tool is decoupled from the
@@ -53,28 +51,38 @@ kubeadm CLI 工具的生命周期与 [kubelet](/zh/docs/reference/command-line-t
<!--
## Kubelet configuration patterns
-->
## Kubelet 配置模式 {#kubelet-configuration-patterns}
<!--
The following sections describe patterns to kubelet configuration that are simplified by
using kubeadm, rather than managing the kubelet configuration for each Node manually.
-->
## Kubelet 配置模式
以下各节讲述了通过使用 kubeadm 简化 kubelet 配置模式,而不是在每个节点上手动地管理 kubelet 配置。
<!--
### Propagating cluster-level configuration to each kubelet
-->
### 将集群级配置传播到每个 kubelet 中 {#propagating-cluster-level-configuration-to-each-kubelet}
<!--
You can provide the kubelet with default values to be used by `kubeadm init` and `kubeadm join`
commands. Interesting examples include using a different container runtime or setting the default subnet
used by services.
If you want your services to use the subnet `10.96.0.0/12` as the default for services, you can pass
the `--service-cidr` parameter to kubeadm:
-->
你可以通过 `kubeadm init``kubeadm join` 命令为 kubelet 提供默认值。
有趣的示例包括使用其他容器运行时或通过服务器设置不同的默认子网。
如果你想使用子网 `10.96.0.0/12` 作为服务的默认网段,你可以给 kubeadm 传递 `--service-cidr` 参数:
```bash
kubeadm init --service-cidr 10.96.0.0/12
```
<!--
Virtual IPs for services are now allocated from this subnet. You also need to set the DNS address used
by the kubelet, using the `--cluster-dns` flag. This setting needs to be the same for every kubelet
on every manager and Node in the cluster. The kubelet provides a versioned, structured API object
@@ -83,27 +91,7 @@ kubelet in the cluster. This object is called
[`KubeletConfiguration`](/docs/reference/config-api/kubelet-config.v1beta1/).
The `KubeletConfiguration` allows the user to specify flags such as the cluster DNS IP addresses expressed as
a list of values to a camelCased key, illustrated by the following example:
```yaml
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
clusterDNS:
- 10.96.0.10
```
For more details on the `KubeletConfiguration` have a look at [this section](#configure-kubelets-using-kubeadm).
-->
### 将集群级配置传播到每个 kubelet 中
你可以通过使用 `kubeadm init``kubeadm join` 命令为 kubelet 提供默认值。
有趣的示例包括使用其他容器运行时或通过服务器设置不同的默认子网。
如果你想使用子网 `10.96.0.0/12` 作为services的默认网段,你可以给 kubeadm 传递 `--service-cidr` 参数:
```bash
kubeadm init --service-cidr 10.96.0.0/12
```
现在,可以从该子网分配服务的虚拟 IP。
你还需要通过 kubelet 使用 `--cluster-dns` 标志设置 DNS 地址。
在集群中的每个管理器和节点上的 kubelet 的设置需要相同。
@@ -118,14 +106,23 @@ clusterDNS:
- 10.96.0.10
```
有关 `KubeletConfiguration` 的更多详细信息,亲参阅[本节](#configure-kubelets-using-kubeadm)。
<!--
For more details on the `KubeletConfiguration` have a look at [this section](#configure-kubelets-using-kubeadm).
-->
有关 `KubeletConfiguration` 的更多详细信息,请参阅[本节](#configure-kubelets-using-kubeadm)。
<!--
### Providing instance-specific configuration details
Some hosts require specific kubelet configurations due to differences in hardware, operating system,
networking, or other host-specific parameters. The following list provides a few examples.
-->
### 提供特定于某实例的配置细节 {#providing-instance-specific-configuration-details}
由于硬件、操作系统、网络或者其他主机特定参数的差异。某些主机需要特定的 kubelet 配置。
以下列表提供了一些示例。
<!--
- The path to the DNS resolution file, as specified by the `--resolv-conf` kubelet
configuration flag, may differ among operating systems, or depending on whether you are using
`systemd-resolved`. If this path is wrong, DNS resolution will fail on the Node whose kubelet
@@ -145,11 +142,6 @@ networking, or other host-specific parameters. The following list provides a few
You can specify these flags by configuring an individual kubelet's configuration in your service manager,
such as systemd.
-->
### 提供指定实例的详细配置信息
由于硬件、操作系统、网络或者其他主机特定参数的差异。某些主机需要特定的 kubelet 配置。
以下列表提供了一些示例。
- 由 kubelet 配置标志 `--resolv-conf` 指定的 DNS 解析文件的路径在操作系统之间可能有所不同,
它取决于你是否使用 `systemd-resolved`
如果此路径错误,则在其 kubelet 配置错误的节点上 DNS 解析也将失败。
@@ -177,7 +169,7 @@ Also have a look at the
[reference for the KubeletConfiguration](/docs/reference/config-api/kubelet-config.v1beta1/)
for more information on the individual fields.
-->
## 使用 kubeadm 配置 kubelet
## 使用 kubeadm 配置 kubelet {#configure-kubelets-using-kubeadm}
如果自定义的 `KubeletConfiguration` API 对象使用像 `kubeadm ... --config some-config-file.yaml` 这样的配置文件进行传递,则可以配置 kubeadm 启动的 kubelet。
@@ -189,7 +181,10 @@ for more information on the individual fields.
<!--
### Workflow when using `kubeadm init`
-->
### 使用 `kubeadm init` 时的工作流程 {#workflow-when-using-kubeadm-init}
<!--
When you call `kubeadm init`, the kubelet configuration is marshalled to disk
at `/var/lib/kubelet/config.yaml`, and also uploaded to a `kubelet-config` ConfigMap in the `kube-system`
namespace of the cluster. A kubelet configuration file is also written to `/etc/kubernetes/kubelet.conf`
@@ -197,53 +192,47 @@ with the baseline cluster-wide configuration for all kubelets in the cluster. Th
points to the client certificates that allow the kubelet to communicate with the API server. This
addresses the need to
[propagate cluster-level configuration to each kubelet](#propagating-cluster-level-configuration-to-each-kubelet).
To address the second pattern of
[providing instance-specific configuration details](#providing-instance-specific-configuration-details),
kubeadm writes an environment file to `/var/lib/kubelet/kubeadm-flags.env`, which contains a list of
flags to pass to the kubelet when it starts. The flags are presented in the file like this:
```bash
KUBELET_KUBEADM_ARGS="--flag1=value1 --flag2=value2 ..."
```
In addition to the flags used when starting the kubelet, the file also contains dynamic
parameters such as the cgroup driver and whether to use a different container runtime socket
(`--cri-socket`).
After marshalling these two files to disk, kubeadm attempts to run the following two
commands, if you are using systemd:
```bash
systemctl daemon-reload && systemctl restart kubelet
```
If the reload and restart are successful, the normal `kubeadm init` workflow continues.
-->
### 当使用 `kubeadm init`时的工作流程
当调用 `kubeadm init` 时,kubelet 的配置会被写入磁盘 `/var/lib/kubelet/config.yaml`
并上传到集群 `kube-system` 命名空间的 `kubelet-config` ConfigMap。
kubelet 配置信息也被写入 `/etc/kubernetes/kubelet.conf`,其中包含集群内所有 kubelet 的基线配置。
此配置文件指向允许 kubelet 与 API 服务器通信的客户端证书。
这解决了[将集群级配置传播到每个 kubelet](#propagating-cluster-level-configuration-to-each-kubelet) 的需求。
该文档 [提供特定实例的配置详细信息](#providing-instance-specific-configuration-details) 是第二种解决模式,
kubeadm 将环境文件写入 `/var/lib/kubelet/kubeadm-flags.env`,其中包含了一个标志列表,
<!--
To address the second pattern of
[providing instance-specific configuration details](#providing-instance-specific-configuration-details),
kubeadm writes an environment file to `/var/lib/kubelet/kubeadm-flags.env`, which contains a list of
flags to pass to the kubelet when it starts. The flags are presented in the file like this:
-->
针对[为特定实例提供配置细节](#providing-instance-specific-configuration-details)的第二种模式,
kubeadm 的解决方法是将环境文件写入 `/var/lib/kubelet/kubeadm-flags.env`,其中包含了一个标志列表,
当 kubelet 启动时,该标志列表会传递给 kubelet 标志在文件中的显示方式如下:
```bash
KUBELET_KUBEADM_ARGS="--flag1=value1 --flag2=value2 ..."
```
除了启动 kubelet 时使用该标志外,该文件还包含动态参数,例如 cgroup 驱动程序以及是否使用其他容器运行时 socket(`--cri-socket`)。
<!--
In addition to the flags used when starting the kubelet, the file also contains dynamic
parameters such as the cgroup driver and whether to use a different container runtime socket
(`--cri-socket`).
-->
除了启动 kubelet 时所使用的标志外,该文件还包含动态参数,例如 cgroup 驱动程序以及是否使用其他容器运行时套接字(`--cri-socket`)。
<!--
After marshalling these two files to disk, kubeadm attempts to run the following two
commands, if you are using systemd:
-->
将这两个文件编组到磁盘后,如果使用 systemd,则 kubeadm 尝试运行以下两个命令:
```bash
systemctl daemon-reload && systemctl restart kubelet
```
<!--
If the reload and restart are successful, the normal `kubeadm init` workflow continues.
-->
如果重新加载和重新启动成功,则正常的 `kubeadm init` 工作流程将继续。
<!--
@@ -254,7 +243,7 @@ a TLS bootstrap, which fetches the credential needed to download the
`kubelet-config` ConfigMap and writes it to `/var/lib/kubelet/config.yaml`. The dynamic
environment file is generated in exactly the same way as `kubeadm init`.
-->
### 使用 `kubeadm join`时的工作流程
### 使用 `kubeadm join` 时的工作流程 {#workflow-when-using-kubeadm-join}
当运行 `kubeadm join` 时,kubeadm 使用 Bootstrap Token 证书执行 TLS 引导,该引导会获取一份证书,
该证书需要下载 `kubelet-config` ConfigMap 并把它写入 `/var/lib/kubelet/config.yaml` 中。
@@ -288,10 +277,17 @@ Kubeadm 在完成 TLS 引导过程后将删除 `/etc/kubernetes/bootstrap-kubele
<!--
## The kubelet drop-in file for systemd
-->
## kubelet 的 systemd drop-in 文件 {#the-kubelet-drop-in-file-for-systemd}
<!--
`kubeadm` ships with configuration for how systemd should run the kubelet.
Note that the kubeadm CLI command never touches this drop-in file.
-->
`kubeadm` 中附带了有关系统如何运行 kubelet 的 systemd 配置文件。
请注意 kubeadm CLI 命令不会修改此文件。
<!--
This configuration file installed by the `kubeadm`
[DEB](https://github.com/kubernetes/release/blob/master/cmd/kubepkg/templates/latest/deb/kubeadm/10-kubeadm.conf) or
[RPM package](https://github.com/kubernetes/release/blob/master/cmd/kubepkg/templates/latest/rpm/kubeadm/10-kubeadm.conf) is written to
@@ -299,13 +295,28 @@ This configuration file installed by the `kubeadm`
It augments the basic
[`kubelet.service` for RPM](https://github.com/kubernetes/release/blob/master/cmd/kubepkg/templates/latest/rpm/kubelet/kubelet.service) or
[`kubelet.service` for DEB](https://github.com/kubernetes/release/blob/master/cmd/kubepkg/templates/latest/deb/kubelet/lib/systemd/system/kubelet.service):
-->
通过 `kubeadm` [DEB 包](https://github.com/kubernetes/release/blob/master/cmd/kubepkg/templates/latest/deb/kubeadm/10-kubeadm.conf)
或者 [RPM 包](https://github.com/kubernetes/release/blob/master/cmd/kubepkg/templates/latest/rpm/kubeadm/10-kubeadm.conf)
安装的配置文件被写入 `/etc/systemd/system/kubelet.service.d/10-kubeadm.conf` 并由 systemd 使用。
它对原来的 [RPM 版本 `kubelet.service`](https://github.com/kubernetes/release/blob/master/cmd/kubepkg/templates/latest/rpm/kubelet/kubelet.service)
或者 [DEB 版本 `kubelet.service`](https://github.com/kubernetes/release/blob/master/cmd/kubepkg/templates/latest/deb/kubelet/lib/systemd/system/kubelet.service)
作了增强:
<!--
{{< note >}}
The contents below are just an example. If you don't want to use a package manager
follow the guide outlined in the [Without a package manager](/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#k8s-install-2))
section.
{{< /note >}}
-->
{{< note >}}
下面的内容只是一个例子。如果你不想使用包管理器,
请遵循[没有包管理器](/zh/docs/setup/productionenvironment/tools/kubeadm/install-kubeadm/#k8s-install-2))
章节的指南。
{{< /note >}}
<!--
```none
[Service]
Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
@@ -313,43 +324,14 @@ Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"
# This is a file that "kubeadm init" and "kubeadm join" generate at runtime, populating
the KUBELET_KUBEADM_ARGS variable dynamically
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
# This is a file that the user can use for overrides of the kubelet args as a last resort.
# Preferably, the user should use the .NodeRegistration.KubeletExtraArgs object in the configuration files instead.
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably,
# the user should use the .NodeRegistration.KubeletExtraArgs object in the configuration files instead.
# KUBELET_EXTRA_ARGS should be sourced from this file.
EnvironmentFile=-/etc/default/kubelet
ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS
```
This file specifies the default locations for all of the files managed by kubeadm for the kubelet.
- The KubeConfig file to use for the TLS Bootstrap is `/etc/kubernetes/bootstrap-kubelet.conf`,
but it is only used if `/etc/kubernetes/kubelet.conf` does not exist.
- The KubeConfig file with the unique kubelet identity is `/etc/kubernetes/kubelet.conf`.
- The file containing the kubelet's ComponentConfig is `/var/lib/kubelet/config.yaml`.
- The dynamic environment file that contains `KUBELET_KUBEADM_ARGS` is sourced from `/var/lib/kubelet/kubeadm-flags.env`.
- The file that can contain user-specified flag overrides with `KUBELET_EXTRA_ARGS` is sourced from
`/etc/default/kubelet` (for DEBs), or `/etc/sysconfig/kubelet` (for RPMs). `KUBELET_EXTRA_ARGS`
is last in the flag chain and has the highest priority in the event of conflicting settings.
-->
## kubelet 的 systemd 文件 {#the-kubelet-drop-in-file-for-systemd}
`kubeadm` 中附带了有关系统如何运行 kubelet 的 systemd 配置文件。
请注意 kubeadm CLI 命令不会修改此文件。
通过 `kubeadm` [DEB](https://github.com/kubernetes/release/blob/master/cmd/kubepkg/templates/latest/deb/kubeadm/10-kubeadm.conf)
或者 [RPM 包](https://github.com/kubernetes/release/blob/master/cmd/kubepkg/templates/latest/rpm/kubeadm/10-kubeadm.conf)
安装的配置文件被写入 `/etc/systemd/system/kubelet.service.d/10-kubeadm.conf` 并由系统使用。
它对原来的 [RPM 版本 `kubelet.service`](https://github.com/kubernetes/release/blob/master/cmd/kubepkg/templates/latest/rpm/kubelet/kubelet.service)
或者 [DEB 版本 `kubelet.service`](https://github.com/kubernetes/release/blob/master/cmd/kubepkg/templates/latest/deb/kubelet/lib/systemd/system/kubelet.service)
作了增强:
{{< note >}}
下面的内容只是一个例子。 如果你不想使用包管理器,
请遵循[没有包管理器](/zh/docs/setup/productionenvironment/tools/kubeadm/install-kubeadm/#k8s-install-2))
部分中叙述的指南。
{{< /note >}}
```none
[Service]
Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
@@ -364,8 +346,21 @@ ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS
```
该文件为 kubelet 指定由 kubeadm 管理的所有文件的默认位置。
<!--
This file specifies the default locations for all of the files managed by kubeadm for the kubelet.
-->
此文件指定由 kubeadm 为 kubelet 管理的所有文件的默认位置。
<!--
- The KubeConfig file to use for the TLS Bootstrap is `/etc/kubernetes/bootstrap-kubelet.conf`,
but it is only used if `/etc/kubernetes/kubelet.conf` does not exist.
- The KubeConfig file with the unique kubelet identity is `/etc/kubernetes/kubelet.conf`.
- The file containing the kubelet's ComponentConfig is `/var/lib/kubelet/config.yaml`.
- The dynamic environment file that contains `KUBELET_KUBEADM_ARGS` is sourced from `/var/lib/kubelet/kubeadm-flags.env`.
- The file that can contain user-specified flag overrides with `KUBELET_EXTRA_ARGS` is sourced from
`/etc/default/kubelet` (for DEBs), or `/etc/sysconfig/kubelet` (for RPMs). `KUBELET_EXTRA_ARGS`
is last in the flag chain and has the highest priority in the event of conflicting settings.
-->
- 用于 TLS 引导程序的 KubeConfig 文件为 `/etc/kubernetes/bootstrap-kubelet.conf`
但仅当 `/etc/kubernetes/kubelet.conf` 不存在时才能使用。
- 具有唯一 kubelet 标识的 KubeConfig 文件为 `/etc/kubernetes/kubelet.conf`
@@ -377,24 +372,26 @@ ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELE
<!--
## Kubernetes binaries and package contents
-->
## Kubernetes 可执行文件和软件包内容 {#kubernetes-binaries-and-package-contents}
<!--
The DEB and RPM packages shipped with the Kubernetes releases are:
-->
Kubernetes 版本对应的 DEB 和 RPM 软件包是:
<!--
| Package name | Description |
|----------------|-------------|
|--------------|-------------|
| `kubeadm` | Installs the `/usr/bin/kubeadm` CLI tool and the [kubelet drop-in file](#the-kubelet-drop-in-file-for-systemd) for the kubelet. |
| `kubelet` | Installs the `/usr/bin/kubelet` binary. |
| `kubectl` | Installs the `/usr/bin/kubectl` binary. |
| `cri-tools` | Installs the `/usr/bin/crictl` binary from the [cri-tools git repository](https://github.com/kubernetes-sigs/cri-tools). |
| `kubernetes-cni` | Installs the `/opt/cni/bin` binaries from the [plugins git repository](https://github.com/containernetworking/plugins). |
-->
## Kubernetes 可执行文件和软件包内容
Kubernetes 版本对应的 DEB 和 RPM 软件包是:
| Package name | Description |
| 软件包名称 | 描述 |
|--------------|-------------|
| `kubeadm` | 给 kubelet 安装 `/usr/bin/kubeadm` CLI 工具和 [kubelet 的 systemd 文件](#the-kubelet-drop-in-file-for-systemd)。 |
| `kubeadm` | 给 kubelet 安装 `/usr/bin/kubeadm` CLI 工具和 [kubelet 的 systemd drop-in 文件](#the-kubelet-drop-in-file-for-systemd)。 |
| `kubelet` | 安装 `/usr/bin/kubelet` 可执行文件。 |
| `kubectl` | 安装 `/usr/bin/kubectl` 可执行文件。 |
| `cri-tools` | 从 [cri-tools git 仓库](https://github.com/kubernetes-sigs/cri-tools)中安装 `/usr/bin/crictl` 可执行文件。 |