@@ -20,10 +20,10 @@ This document describes how to configure and use kernel parameters within a
20
20
Kubernetes cluster using the {{< glossary_tooltip term_id="sysctl" >}}
21
21
interface.
22
22
-->
23
-
24
23
本文档介绍如何通过 {{< glossary_tooltip term_id="sysctl" >}}
25
24
接口在 Kubernetes 集群中配置和使用内核参数。
26
25
26
+ {{< note >}}
27
27
<!--
28
28
Starting from Kubernetes version 1.23, the kubelet supports the use of either `/` or `.`
29
29
as separators for sysctl names.
@@ -34,7 +34,6 @@ For more sysctl parameter conversion method details, please refer to
34
34
the page [sysctl.d(5)](https://man7.org/linux/man-pages/man5/sysctl.d.5.html) from
35
35
the Linux man-pages project.
36
36
-->
37
- {{< note >}}
38
37
从 Kubernetes 1.23 版本开始,kubelet 支持使用 ` / ` 或 ` . ` 作为 sysctl 参数的分隔符。
39
38
从 Kubernetes 1.25 版本开始,支持为 Pod 设置 sysctl 时使用设置名字带有斜线的 sysctl。
40
39
例如,你可以使用点或者斜线作为分隔符表示相同的 sysctl 参数,以点作为分隔符表示为: ` kernel.shm_rmid_forced ` ,
@@ -58,7 +57,7 @@ options for the kubelets running on your cluster.
58
57
<!--
59
58
## Listing all Sysctl Parameters
60
59
-->
61
- ## 获取 Sysctl 的参数列表
60
+ ## 获取 Sysctl 的参数列表 {#listing-all-sysctl-parameters}
62
61
63
62
<!--
64
63
In Linux, the sysctl interface allows an administrator to modify kernel
@@ -91,17 +90,17 @@ sudo sysctl -a
91
90
```
92
91
93
92
<!--
94
- ## Enabling Unsafe Sysctls
93
+ ## Safe and Unsafe Sysctls
95
94
96
- Sysctls are grouped into _safe_ and _unsafe_ sysctls . In addition to proper
97
- namespacing a _safe_ sysctl must be properly _isolated_ between pods on the same
98
- node. This means that setting a _safe_ sysctl for one pod
95
+ Kubernetes classes sysctls as either _safe_ or _unsafe_. In addition to proper
96
+ namespacing, a _safe_ sysctl must be properly _isolated_ between pods on the
97
+ same node. This means that setting a _safe_ sysctl for one pod
99
98
-->
100
- ## 启用非安全的 Sysctl 参数 {#enabling-usafe -sysctls}
99
+ ## 安全和非安全的 Sysctl 参数 {#safe-and-unsafe -sysctls}
101
100
102
- sysctl 参数分为 ** 安全** 和 ** 非安全的** 。
103
- ** 安全** 的 sysctl 参数除了需要设置恰当的命名空间外,在同一节点上的不同 Pod
104
- 之间也必须是 ** 相互隔离的** 。这意味着 Pod 上设置 ** 安全 ** sysctl 参数 :
101
+ Kubernetes 将 sysctl 参数分为 ** 安全** 和 ** 非安全的** 。
102
+ ** 安全** 的 sysctl 参数除了需要设置恰当的命名空间外,在同一节点上的不同 Pod
103
+ 之间也必须是 ** 相互隔离的** 。这意味着 Pod 上设置 ** 安全的 ** sysctl 参数时 :
105
104
106
105
<!--
107
106
- must not have any influence on any other pod on the node
@@ -126,10 +125,10 @@ The following sysctls are supported in the _safe_ set:
126
125
- ` net.ipv4.ping_group_range ` (从 Kubernetes 1.18 开始)
127
126
- ` net.ipv4.ip_unprivileged_port_start ` (从 Kubernetes 1.22 开始)。
128
127
128
+ {{< note >}}
129
129
<!--
130
130
The example `net.ipv4.tcp_syncookies` is not namespaced on Linux kernel version 4.4 or lower.
131
131
-->
132
- {{< note >}}
133
132
示例中的 ` net.ipv4.tcp_syncookies ` 在Linux 内核 4.4 或更低的版本中是无命名空间的。
134
133
{{< /note >}}
135
134
@@ -141,8 +140,12 @@ supports better isolation mechanisms.
141
140
则上述列表中将会列出更多 ** 安全的** sysctl 参数。
142
141
143
142
<!--
143
+ ### Enabling Unsafe Sysctls
144
+
144
145
All _safe_ sysctls are enabled by default.
145
146
-->
147
+ ### 启用非安全的 Sysctl 参数 {#enabling-unsafe-sysctls}
148
+
146
149
所有 ** 安全的** sysctl 参数都默认启用。
147
150
148
151
<!--
@@ -188,10 +191,10 @@ A number of sysctls are _namespaced_ in today's Linux kernels. This means that
188
191
they can be set independently for each pod on a node. Only namespaced sysctls
189
192
are configurable via the pod securityContext within Kubernetes.
190
193
-->
191
- ## 设置 Pod 的 Sysctl 参数
194
+ ## 设置 Pod 的 Sysctl 参数 {#setting-sysctls-for-pod}
192
195
193
- 目前,在 Linux 内核中,有许多的 sysctl 参数都是 ** 有命名空间的** 。
194
- 这就意味着可以为节点上的每个 Pod 分别去设置它们的 sysctl 参数。
196
+ 目前,在 Linux 内核中,有许多的 sysctl 参数都是 ** 有命名空间的** 。
197
+ 这就意味着可以为节点上的每个 Pod 分别去设置它们的 sysctl 参数。
195
198
在 Kubernetes 中,只有那些有命名空间的 sysctl 参数可以通过 Pod 的 securityContext 对其进行配置。
196
199
197
200
<!--
@@ -235,11 +238,11 @@ the specification.
235
238
` net.core.somaxconn ` 和 ` kernel.msgmax ` 进行设置。
236
239
在 Pod 规约中对 ** 安全的** 和 ** 非安全的** sysctl 参数不做区分。
237
240
241
+ {{< warning >}}
238
242
<!--
239
243
Only modify sysctl parameters after you understand their effects, to avoid
240
244
destabilizing your operating system.
241
245
-->
242
- {{< warning >}}
243
246
为了避免破坏操作系统的稳定性,请你在了解变更后果之后再修改 sysctl 参数。
244
247
{{< /warning >}}
245
248
@@ -262,12 +265,12 @@ spec:
262
265
263
266
<!-- discussion -->
264
267
268
+ {{< warning >}}
265
269
<!--
266
270
Due to their nature of being _unsafe_, the use of _unsafe_ sysctls
267
271
is at-your-own-risk and can lead to severe problems like wrong behavior of
268
272
containers, resource shortage or complete breakage of a node.
269
273
-->
270
- {{< warning >}}
271
274
由于 ** 非安全的** sysctl 参数其本身具有不稳定性,在使用 ** 非安全的** sysctl 参数时可能会导致一些严重问题,
272
275
如容器的错误行为、机器资源不足或节点被完全破坏,用户需自行承担风险。
273
276
{{< /warning >}}
@@ -295,6 +298,3 @@ to schedule those pods onto the right nodes.
295
298
建议开启[ 污点和容忍度特性] ( /docs/reference/generated/kubectl/kubectl-commands/#taint ) 或
296
299
[ 为节点配置污点] ( /zh-cn/docs/concepts/scheduling-eviction/taint-and-toleration/ ) 以便将
297
300
Pod 调度到正确的节点之上。
298
-
299
-
300
-
0 commit comments