|
| 1 | +--- |
| 2 | +content_type: "reference" |
| 3 | +title: Linux 内核版本要求 |
| 4 | +weight: 10 |
| 5 | +--- |
| 6 | +<!-- |
| 7 | +content_type: "reference" |
| 8 | +title: Linux Kernel Version Requirements |
| 9 | +weight: 10 |
| 10 | +--> |
| 11 | + |
| 12 | +{{% thirdparty-content %}} |
| 13 | + |
| 14 | +<!-- |
| 15 | +Many features rely on specific kernel functionalities and have minimum kernel version requirements. |
| 16 | +However, relying solely on kernel version numbers may not be sufficient |
| 17 | +for certain operating system distributions, |
| 18 | +as maintainers for distributions such as RHEL, Ubuntu and SUSE often backport selected features |
| 19 | +to older kernel releases (retaining the older kernel version). |
| 20 | +--> |
| 21 | +许多特性依赖于特定的内核功能,并且有最低的内核版本要求。 |
| 22 | +然而,单纯依赖内核版本号可能不足以满足某些操作系统发行版, |
| 23 | +因为像 RHEL、Ubuntu 和 SUSE 等发行版的维护者们通常会将选定的特性反向移植到较旧的内核版本(保留较旧的内核版本)。 |
| 24 | + |
| 25 | +## Pod sysctls |
| 26 | + |
| 27 | +<!-- |
| 28 | +On Linux, the `sysctl()` system call configures kernel parameters at run time. There is a command |
| 29 | +line tool named `sysctl` that you can use to configure these parameters, and many are exposed via |
| 30 | +the `proc` filesystem. |
| 31 | +
|
| 32 | +Some sysctls are only available if you have a modern enough kernel. |
| 33 | +
|
| 34 | +The following sysctls have a minimal kernel version requirement, |
| 35 | +and are supported in the [safe set](/docs/tasks/administer-cluster/sysctl-cluster/#safe-and-unsafe-sysctls): |
| 36 | +--> |
| 37 | +在 Linux 中,`sysctl()` 系统调用在运行时配置内核参数。 |
| 38 | +你可以使用名为 `sysctl` 的命令行工具来配置这些参数,许多参数通过 `proc` 文件系统暴露。 |
| 39 | + |
| 40 | +某些 sysctl 仅可用于足够新的内核上。 |
| 41 | + |
| 42 | +以下 sysctl 具有最低的内核版本要求, |
| 43 | +并在[安全集](/zh-cn/docs/tasks/administer-cluster/sysctl-cluster/#safe-and-unsafe-sysctls)中得到了支持: |
| 44 | + |
| 45 | +<!-- |
| 46 | +Code: https://github.com/kubernetes/kubernetes/blob/00236ae0d73d2455a2470469ed1005674f8ed61f/pkg/util/kernel/constants.go#L19-L45 |
| 47 | +--> |
| 48 | + |
| 49 | +<!-- |
| 50 | +- `net.ipv4.ip_local_reserved_ports` (since Kubernetes 1.27, needs kernel 3.16+); |
| 51 | +- `net.ipv4.tcp_keepalive_time` (since Kubernetes 1.29, needs kernel 4.5+); |
| 52 | +- `net.ipv4.tcp_fin_timeout` (since Kubernetes 1.29, needs kernel 4.6+); |
| 53 | +- `net.ipv4.tcp_keepalive_intvl` (since Kubernetes 1.29, needs kernel 4.5+); |
| 54 | +- `net.ipv4.tcp_keepalive_probes` (since Kubernetes 1.29, needs kernel 4.5+); |
| 55 | +- `net.ipv4.tcp_syncookies` (namespaced since kernel 4.6+). |
| 56 | +- `net.ipv4.vs.conn_reuse_mode` (used in `ipvs` proxy mode, needs kernel 4.1+); |
| 57 | +
|
| 58 | +### kube proxy `nftables` proxy mode |
| 59 | +--> |
| 60 | +- `net.ipv4.ip_local_reserved_ports`(自 Kubernetes 1.27 起,需要内核 3.16+); |
| 61 | +- `net.ipv4.tcp_keepalive_time`(自 Kubernetes 1.29 起,需要内核 4.5+); |
| 62 | +- `net.ipv4.tcp_fin_timeout`(自 Kubernetes 1.29 起,需要内核 4.6+); |
| 63 | +- `net.ipv4.tcp_keepalive_intvl`(自 Kubernetes 1.29 起,需要内核 4.5+); |
| 64 | +- `net.ipv4.tcp_keepalive_probes`(自 Kubernetes 1.29 起,需要内核 4.5+); |
| 65 | +- `net.ipv4.tcp_syncookies`(自内核 4.6+ 添加了命名空间作用域)。 |
| 66 | +- `net.ipv4.vs.conn_reuse_mode`(用于 `ipvs` 代理模式,需要内核 4.1+); |
| 67 | + |
| 68 | +### kube proxy `nftables` 代理模式 {#kube-proxy-nftables-proxy-mode} |
| 69 | + |
| 70 | +<!-- |
| 71 | +Code: https://github.com/kubernetes/kubernetes/blob/00236ae0d73d2455a2470469ed1005674f8ed61f/pkg/util/kernel/constants.go#L53-L56 |
| 72 | +--> |
| 73 | + |
| 74 | +<!-- |
| 75 | +For Kubernetes {{< skew currentVersion >}}, the |
| 76 | +[`nftables` mode](/docs/reference/networking/virtual-ips/#proxy-mode-nftables) of kube-proxy requires |
| 77 | +version 1.0.1 or later |
| 78 | +of the nft command-line tool, as well as kernel 5.13 or later. |
| 79 | +
|
| 80 | +For testing/development purposes, you can use older kernels, as far back as 5.4 if you set the |
| 81 | +`nftables.skipKernelVersionCheck` option in the kube-proxy config. |
| 82 | +But this is not recommended in production since it may cause problems with other nftables |
| 83 | +users on the system. |
| 84 | +--> |
| 85 | +对于 Kubernetes {{< skew currentVersion >}},kube-proxy 的 |
| 86 | +[`nftables` 模式](/zh-cn/docs/reference/networking/virtual-ips/#proxy-mode-nftables)要求 |
| 87 | +nft 命令行工具为 v1.0.1 或更高版本,要求内核为 v5.13 或更高版本。 |
| 88 | + |
| 89 | +出于测试/开发目的,你可以使用较旧的内核,如果你在 kube-proxy 配置中设置 `nftables.skipKernelVersionCheck` 选项, |
| 90 | +最老可以回溯到 v5.4。但在生产环境中不推荐这样做,因为这可能会导致系统上其他 nftables 用户出现问题。 |
| 91 | + |
| 92 | +<!-- |
| 93 | +## Version 2 control groups |
| 94 | +
|
| 95 | +Kubernetes cgroup v1 support is in maintained mode starting from Kubernetes v1.31; using cgroup v2 |
| 96 | +is recommended. |
| 97 | +In [Linux 5.8](https://github.com/torvalds/linux/commit/4a7e89c5ec0238017a757131eb9ab8dc111f961c), the system-level `cpu.stat` file was added to the root cgroup for convenience. |
| 98 | +
|
| 99 | +In runc document, Kernel older than 5.2 is not recommended due to lack of freezer. |
| 100 | +--> |
| 101 | +## v2 控制组 {#version2-control-groups} |
| 102 | + |
| 103 | +Kubernetes 对 cgroup v1 的支持从 v1.31 开始处于维护模式;推荐使用 cgroup v2。 |
| 104 | +在 [Linux 5.8](https://github.com/torvalds/linux/commit/4a7e89c5ec0238017a757131eb9ab8dc111f961c) |
| 105 | +中,为了方便使用,系统层面的 `cpu.stat` 文件被添加到根 cgroup。 |
| 106 | + |
| 107 | +在 runc 文档中,不推荐使用低于 5.2 的内核,因为其缺少冻结特性。 |
| 108 | + |
| 109 | +<!-- |
| 110 | +## Other kernel requirements {#requirements-other} |
| 111 | +
|
| 112 | +Some features may depend on new kernel functionalities and have specific kernel requirements: |
| 113 | +--> |
| 114 | +## 其他内核要求 {#requirements-other} |
| 115 | + |
| 116 | +某些特性可能依赖于新的内核功能并具有特定的内核要求: |
| 117 | + |
| 118 | +<!-- |
| 119 | +Code(recursive read only mount): https://github.com/kubernetes/kubernetes/blob/00236ae0d73d2455a2470469ed1005674f8ed61f/staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto#L1605-L1609 |
| 120 | +Code(user namespace and swap): https://github.com/kubernetes/kubernetes/blob/00236ae0d73d2455a2470469ed1005674f8ed61f/pkg/util/kernel/constants.go#L47-L51 |
| 121 | +--> |
| 122 | + |
| 123 | +<!-- |
| 124 | +1. [Recursive read only mount](/docs/concepts/storage/volumes/#recursive-read-only-mounts): |
| 125 | + This is implemented by applying the `MOUNT_ATTR_RDONLY` attribute with the `AT_RECURSIVE` flag |
| 126 | + using `mount_setattr`(2) added in Linux kernel v5.12. |
| 127 | +2. Pod user namespace support requires minimal kernel version 6.5+, according to |
| 128 | + [KEP-127](https://github.com/kubernetes/enhancements/blob/master/keps/sig-node/127-user-namespaces/README.md). |
| 129 | +3. For [node system swap](/docs/concepts/architecture/nodes/#swap-memory), tmpfs set to `noswap` |
| 130 | + is not supported until kernel 6.3. |
| 131 | +--> |
| 132 | +1. [递归只读挂载](/zh-cn/docs/concepts/storage/volumes/#recursive-read-only-mounts): |
| 133 | + 这是通过应用 `MOUNT_ATTR_RDONLY` 属性和 `AT_RECURSIVE` 标志来实现的,使用的是在 Linux |
| 134 | + 内核 v5.12 中添加的 `mount_setattr`(2)。 |
| 135 | +2. Pod 用户命名空间支持需要最低内核版本 6.5+,参阅 |
| 136 | + [KEP-127](https://github.com/kubernetes/enhancements/blob/master/keps/sig-node/127-user-namespaces/README.md)。 |
| 137 | +3. 对于[节点系统交换](/zh-cn/docs/concepts/architecture/nodes/#swap-memory), |
| 138 | + 直到内核 6.3 才支持将 tmpfs 设置为 `noswap`。 |
| 139 | + |
| 140 | +<!-- |
| 141 | +## Linux kernel long term maintenance |
| 142 | +
|
| 143 | +Active kernel releases can be found in [kernel.org](https://www.kernel.org/category/releases.html). |
| 144 | +
|
| 145 | +There are usually several _long term maintenance_ kernel releases provided for the purposes of backporting |
| 146 | +bug fixes for older kernel trees. Only important bug fixes are applied to such kernels and they don't |
| 147 | +usually see very frequent releases, especially for older trees. |
| 148 | +See the Linux kernel website for the [list of releases](https://www.kernel.org/category/releases.html) |
| 149 | +in the _Longterm_ category. |
| 150 | +--> |
| 151 | +## Linux 内核长期维护 {#linux-kernel-long-term-maintenance} |
| 152 | + |
| 153 | +你可以在 [kernel.org](https://www.kernel.org/category/releases.html) 找到活动的内核版本。 |
| 154 | + |
| 155 | +通常会提供多个 __长期维护__ 内核版本,用于将 Bug 修复反向移植到较旧的内核树。 |
| 156 | +特别是对于较旧的树,只有重要的 Bug 修复才会被应用到此类内核,这些内核通常不会频繁发布新版本。 |
| 157 | +请参阅 Linux 内核网站,了解 _Longterm_ 类别中的[发布列表](https://www.kernel.org/category/releases.html)。 |
| 158 | + |
| 159 | +## {{% heading "whatsnext" %}} |
| 160 | + |
| 161 | +<!-- |
| 162 | +- See [sysctls](/docs/tasks/administer-cluster/sysctl-cluster/) for more details. |
| 163 | +- Allow running kube-proxy with in [nftables mode](/docs/reference/networking/virtual-ips/#proxy-mode-nftables). |
| 164 | +- Read more information in [cgroups v2](/docs/concepts/architecture/cgroups/). |
| 165 | +--> |
| 166 | +- 查阅 [sysctls](/zh-cn/docs/tasks/administer-cluster/sysctl-cluster/) 以获取更多细节。 |
| 167 | +- 允许在 [nftables 模式](/zh-cn/docs/reference/networking/virtual-ips/#proxy-mode-nftables)下运行 kube-proxy。 |
| 168 | +- 参阅 [cgroups v2](/zh-cn/docs/concepts/architecture/cgroups/)。 |
0 commit comments