Skip to content

Commit e59c484

Browse files
authored
Merge pull request #41623 from my-git9/ip-masq-agent3
[zh-cn] sync and improve resource-usage-monitoring ip-masq-agent audit
2 parents ca44c77 + 824822d commit e59c484

File tree

3 files changed

+52
-51
lines changed

3 files changed

+52
-51
lines changed

content/zh-cn/docs/tasks/administer-cluster/ip-masq-agent.md

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ cluster's pod [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routin
3636
范围之外的目的地时使用。
3737

3838
<!--
39-
### **Key Terms**
39+
### Key Terms
4040
-->
41-
### **关键术语** {#key-terms}
41+
### 关键术语 {#key-terms}
4242

4343
<!--
44-
* **NAT (Network Address Translation)**
44+
* **NAT (Network Address Translation)**:
4545
Is a method of remapping one IP address to another by modifying either the source and/or
4646
destination address information in the IP header. Typically performed by a device doing IP routing.
4747
-->
48-
* **NAT (网络地址转换)**
48+
* **NAT网络地址转换**
4949
是一种通过修改 IP 地址头中的源和/或目标地址信息将一个 IP 地址重新映射
5050
到另一个 IP 地址的方法。通常由执行 IP 路由的设备执行。
5151

@@ -55,7 +55,7 @@ cluster's pod [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routin
5555
multiple source IP addresses are masked behind a single address, which is typically the
5656
device doing the IP routing. In Kubernetes this is the Node's IP address.
5757
-->
58-
* **伪装**
58+
* **伪装**
5959
NAT 的一种形式,通常用于执行多对一地址转换,其中多个源 IP 地址被隐藏在
6060
单个地址后面,该地址通常是执行 IP 路由的设备。在 Kubernetes 中,
6161
这是节点的 IP 地址。
@@ -67,18 +67,18 @@ cluster's pod [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routin
6767
**CIDR notation**, in which an address or routing prefix is written with a suffix indicating
6868
the number of bits of the prefix, such as 192.168.2.0/24.
6969
-->
70-
* **CIDR (无类别域间路由)**
70+
* **CIDR无类别域间路由**
7171
基于可变长度子网掩码,允许指定任意长度的前缀。
72-
CIDR 引入了一种新的 IP 地址表示方法,现在通常称为**CIDR表示法**
72+
CIDR 引入了一种新的 IP 地址表示方法,现在通常称为 **CIDR 表示法**
7373
其中地址或路由前缀后添加一个后缀,用来表示前缀的位数,例如 192.168.2.0/24。
7474

7575
<!--
76-
* **Link Local**
76+
* Link Local
7777
A link-local address is a network address that is valid only for communications within the
7878
network segment or the broadcast domain that the host is connected to. Link-local addresses
7979
for IPv4 are defined in the address block 169.254.0.0/16 in CIDR notation.
8080
-->
81-
* **本地链路**
81+
* **本地链路**
8282
本地链路是仅对网段或主机所连接的广播域内的通信有效的网络地址。
8383
IPv4 的本地链路地址在 CIDR 表示法的地址块 169.254.0.0/16 中定义。
8484

@@ -98,19 +98,19 @@ The agent will also treat link-local (169.254.0.0/16) as a non-masquerade CIDR b
9898
The agent is configured to reload its configuration from the location
9999
*/etc/config/ip-masq-agent* every 60 seconds, which is also configurable.
100100
-->
101-
ip-masq-agent 配置 iptables 规则,以便在将流量发送到集群节点的 IP 和集群 IP 范围之外的目标时
102-
处理伪装节点或 Pod 的 IP 地址。这本质上隐藏了集群节点 IP 地址后面的 Pod IP 地址。
103-
在某些环境中,去往“外部”地址的流量必须从已知的机器地址发出。
101+
ip-masq-agent 配置 iptables 规则,以便在将流量发送到集群节点的 IP 和集群 IP
102+
范围之外的目标时处理伪装节点或 Pod 的 IP 地址。这本质上隐藏了集群节点 IP 地址后面的
103+
Pod IP 地址。在某些环境中,去往"外部"地址的流量必须从已知的机器地址发出。
104104
例如,在 Google Cloud 中,任何到互联网的流量都必须来自 VM 的 IP。
105105
使用容器时,如 Google Kubernetes Engine,从 Pod IP 发出的流量将被拒绝出站。
106-
为了避免这种情况,我们必须将 Pod IP 隐藏在 VM 自己的 IP 地址后面 - 通常称为“伪装”
106+
为了避免这种情况,我们必须将 Pod IP 隐藏在 VM 自己的 IP 地址后面 - 通常称为"伪装"
107107
默认情况下,代理配置为将
108108
[RFC 1918](https://tools.ietf.org/html/rfc1918)
109109
指定的三个私有 IP 范围视为非伪装
110110
[CIDR](https://zh.wikipedia.org/wiki/%E6%97%A0%E7%B1%BB%E5%88%AB%E5%9F%9F%E9%97%B4%E8%B7%AF%E7%94%B1)
111-
这些范围是 10.0.0.0/8,172.16.0.0/12 和 192.168.0.0/16。
111+
这些范围是 10.0.0.0/8172.16.0.0/12 和 192.168.0.0/16。
112112
默认情况下,代理还将链路本地地址(169.254.0.0/16)视为非伪装 CIDR。
113-
代理程序配置为每隔 60 秒从 */etc/config/ip-masq-agent* 重新加载其配置,
113+
代理程序配置为每隔 60 秒从 **/etc/config/ip-masq-agent** 重新加载其配置,
114114
这也是可修改的。
115115

116116
![masq/non-masq example](/images/docs/ip-masq.png)
@@ -134,8 +134,8 @@ optional keys:
134134
* `masqLinkLocal`: A Boolean (true/false) which indicates whether to masquerade traffic to the
135135
link local prefix `169.254.0.0/16`. False by default.
136136
-->
137-
* `masqLinkLocal`:布尔值 (true/false),表示是否为本地链路前缀 169.254.0.0/16 的流量提供伪装。
138-
默认为 false。
137+
* `masqLinkLocal`:布尔值true/false,表示是否为本地链路前缀 `169.254.0.0/16`
138+
的流量提供伪装。默认为 false。
139139

140140
<!--
141141
* `resyncInterval`: A time interval at which the agent attempts to reload config from disk.
@@ -146,7 +146,7 @@ optional keys:
146146

147147
<!--
148148
Traffic to 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 ranges will NOT be masqueraded. Any
149-
other traffic (assumed to be internet) will be masqueraded. An example of a local destination
149+
other traffic (assumed to be internet) will be masqueraded. An example of a local destination
150150
from a pod could be its Node's IP address as well as another node's address or one of the IP
151151
addresses in Cluster's IP range. Any other traffic will be masqueraded by default. The
152152
below entries show the default set of rules that are applied by the ip-masq-agent:
@@ -180,17 +180,19 @@ to your cluster.
180180
或者你使用的集群 CIDR 不在 10.0.0.0/8 范围内,
181181
`ip-masq-agent` 将在你的集群中运行。
182182
如果你在其他环境中运行,可以将 `ip-masq-agent`
183-
[DaemonSet](/zh-cn/docs/concepts/workloads/controllers/daemonset/) 添加到你的集群中。
183+
[DaemonSet](/zh-cn/docs/concepts/workloads/controllers/daemonset/)
184+
添加到你的集群中。
184185

185186
<!-- steps -->
186187

187188
<!--
188189
## Create an ip-masq-agent
190+
189191
To create an ip-masq-agent, run the following kubectl command:
190192
-->
191193
## 创建 ip-masq-agent {#create-ip-masq-agent}
192194

193-
通过运行以下 kubectl 指令创建 ip-masq-agent:
195+
通过运行以下 kubectl 指令创建 ip-masq-agent
194196

195197
```shell
196198
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/ip-masq-agent/master/ip-masq-agent.yaml
@@ -207,31 +209,31 @@ kubectl label nodes my-node node.kubernetes.io/masq-agent-ds-ready=true
207209
```
208210

209211
<!--
210-
More information can be found in the ip-masq-agent documentation [here](https://github.com/kubernetes-sigs/ip-masq-agent)
212+
More information can be found in the ip-masq-agent documentation [here](https://github.com/kubernetes-sigs/ip-masq-agent).
211213
-->
212214
更多信息可以通过 ip-masq-agent 文档[这里](https://github.com/kubernetes-sigs/ip-masq-agent)找到。
213215

214216
<!--
215217
In most cases, the default set of rules should be sufficient; however, if this is not the case
216218
for your cluster, you can create and apply a
217219
[ConfigMap](/docs/tasks/configure-pod-container/configure-pod-configmap/) to customize the IP
218-
ranges that are affected. For example, to allow
220+
ranges that are affected. For example, to allow
219221
only 10.0.0.0/8 to be considered by the ip-masq-agent, you can create the following
220222
[ConfigMap](/docs/tasks/configure-pod-container/configure-pod-configmap/) in a file called
221223
"config".
222224
-->
223225
在大多数情况下,默认的规则集应该足够;但是,如果你的集群不是这种情况,则可以创建并应用
224226
[ConfigMap](/zh-cn/docs/tasks/configure-pod-container/configure-pod-configmap/)
225227
来自定义受影响的 IP 范围。
226-
例如,要允许 ip-masq-agent 仅作用于 10.0.0.0/8,你可以在一个名为 config 的文件中创建以下
227-
[ConfigMap](/zh-cn/docs/tasks/configure-pod-container/configure-pod-configmap/)
228+
例如,要允许 ip-masq-agent 仅作用于 10.0.0.0/8,你可以在一个名为 "config" 的文件中创建以下
229+
[ConfigMap](/zh-cn/docs/tasks/configure-pod-container/configure-pod-configmap/)
228230

229231
{{< note >}}
230232
<!--
231233
It is important that the file is called config since, by default, that will be used as the key
232234
for lookup by the `ip-masq-agent`:
233235
-->
234-
重要的是,该文件之所以被称为 config,因为默认情况下,该文件将被用作
236+
重要的是,该文件之所以被称为 config,是因为默认情况下,该文件将被用作
235237
`ip-masq-agent` 查找的主键:
236238

237239
```yaml
@@ -242,7 +244,7 @@ resyncInterval: 60s
242244
{{< /note >}}
243245
244246
<!--
245-
Run the following command to add the config map to your cluster:
247+
Run the following command to add the configmap to your cluster:
246248
-->
247249
运行以下命令将 ConfigMap 添加到你的集群:
248250
@@ -276,8 +278,8 @@ By default, the link local range (169.254.0.0/16) is also handled by the ip-masq
276278
sets up the appropriate iptables rules. To have the ip-masq-agent ignore link local, you can
277279
set `masqLinkLocal` to true in the ConfigMap.
278280
-->
279-
默认情况下,本地链路范围 (169.254.0.0/16) 也由 ip-masq agent 处理,
280-
该代理设置适当的 iptables 规则。 要使 ip-masq-agent 忽略本地链路,
281+
默认情况下,本地链路范围169.254.0.0/16也由 ip-masq agent 处理,
282+
该代理设置适当的 iptables 规则。要使 ip-masq-agent 忽略本地链路,
281283
可以在 ConfigMap 中将 `masqLinkLocal` 设置为 true。
282284

283285
```yaml

content/zh-cn/docs/tasks/debug/debug-cluster/audit.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ by applications that use the Kubernetes API, and by the control plane itself.
1919
2020
Auditing allows cluster administrators to answer the following questions:
2121
-->
22-
Kubernetes **审计(Auditing)** 功能提供了与安全相关的、按时间顺序排列的记录集,
22+
Kubernetes**审计(Auditing)**功能提供了与安全相关的、按时间顺序排列的记录集,
2323
记录每个用户、使用 Kubernetes API 的应用以及控制面自身引发的活动。
2424

2525
审计功能使得集群管理员能够回答以下问题:
@@ -54,9 +54,8 @@ include logs files and webhooks.
5454
-->
5555
审计记录最初产生于
5656
[kube-apiserver](/zh-cn/docs/reference/command-line-tools-reference/kube-apiserver/)
57-
内部。每个请求在不同执行阶段都会生成审计事件;这些审计事件会根据特定策略
58-
被预处理并写入后端。策略确定要记录的内容和用来存储记录的后端。
59-
当前的后端支持日志文件和 webhook。
57+
内部。每个请求在不同执行阶段都会生成审计事件;这些审计事件会根据特定策略被预处理并写入后端。
58+
策略确定要记录的内容和用来存储记录的后端,当前的后端支持日志文件和 webhook。
6059

6160
<!--
6261
Each request can be recorded with an associated _stage_. The defined stages are:
@@ -73,8 +72,8 @@ Each request can be recorded with an associated _stage_. The defined stages are:
7372
-->
7473
每个请求都可被记录其相关的**阶段(stage)**。已定义的阶段有:
7574

76-
- `RequestReceived` - 此阶段对应审计处理器接收到请求后,并且在委托给
77-
其余处理器之前生成的事件
75+
- `RequestReceived` - 此阶段对应审计处理器接收到请求后,
76+
并且在委托给其余处理器之前生成的事件
7877
- `ResponseStarted` - 在响应消息的头部发送后,响应消息体发送前生成的事件。
7978
只有长时间运行的请求(例如 watch)才会生成这个阶段。
8079
- `ResponseComplete` - 当响应消息体完成并且没有更多数据需要传输的时候。
@@ -115,9 +114,9 @@ _audit level_ of the event. The defined audit levels are:
115114

116115
审计策略定义了关于应记录哪些事件以及应包含哪些数据的规则。
117116
审计策略对象结构定义在
118-
[`audit.k8s.io` API 组](/zh-cn/docs/reference/config-api/apiserver-audit.v1/#audit-k8s-io-v1-Policy)
119-
处理事件时,将按顺序与规则列表进行比较。第一个匹配规则设置事件的
120-
**审计级别(Audit Level)**已定义的审计级别有:
117+
[`audit.k8s.io` API 组](/zh-cn/docs/reference/config-api/apiserver-audit.v1/#audit-k8s-io-v1-Policy)
118+
处理事件时,将按顺序与规则列表进行比较。第一个匹配规则设置事件的**审计级别(Audit Level)**
119+
已定义的审计级别有:
121120

122121
<!--
123122
- `None` - don't log events that match this rule.
@@ -194,7 +193,7 @@ In all cases, audit events follow a structure defined by the Kubernetes API in t
194193
-->
195194
## 审计后端 {#audit-backends}
196195

197-
审计后端实现将审计事件导出到外部存储。`Kube-apiserver` 默认提供两个后端:
196+
审计后端实现将审计事件导出到外部存储。`kube-apiserver` 默认提供两个后端:
198197

199198
- Log 后端,将事件写入到文件系统
200199
- Webhook 后端,将事件发送到外部 HTTP API
@@ -210,7 +209,7 @@ with an appropriate Kubernetes API object. For example, the following request bo
210209
request to `/apis/batch/v1/namespaces/some-namespace/jobs/some-job-name`:
211210
-->
212211
对于 patch 请求,请求的消息体需要是设定 patch 操作的 JSON 所构成的一个串,
213-
而不是一个完整的 Kubernetes API 对象 JSON 串。
212+
而不是一个完整的 Kubernetes API 对象的 JSON 串。
214213
例如,以下的示例是一个合法的 patch 请求消息体,该请求对应
215214
`/apis/batch/v1/namespaces/some-namespace/jobs/some-job-name`
216215

@@ -237,7 +236,7 @@ You can configure the log audit backend using the following `kube-apiserver` fla
237236
-->
238237
### Log 后端 {#log-backend}
239238

240-
Log 后端将审计事件写入 [JSONlines](https://jsonlines.org/) 格式的文件。
239+
Log 后端将审计事件写入 [JSONlines](https://jsonlines.org/) 格式的文件。
241240
你可以使用以下 `kube-apiserver` 标志配置 Log 审计后端:
242241

243242
<!--
@@ -259,9 +258,9 @@ to the location of the policy file and log file, so that audit records are persi
259258
如果你的集群控制面以 Pod 的形式运行 kube-apiserver,记得要通过 `hostPath`
260259
卷来访问策略文件和日志文件所在的目录,这样审计记录才会持久保存下来。例如:
261260

262-
```shell
263-
--audit-policy-file=/etc/kubernetes/audit-policy.yaml \
264-
--audit-log-path=/var/log/kubernetes/audit/audit.log
261+
```yaml
262+
- --audit-policy-file=/etc/kubernetes/audit-policy.yaml
263+
- --audit-log-path=/var/log/kubernetes/audit/audit.log
265264
```
266265

267266
<!--

content/zh-cn/docs/tasks/debug/debug-cluster/resource-usage-monitoring.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ This information allows you to evaluate your application's performance and
2525
where bottlenecks can be removed to improve overall performance.
2626
-->
2727
要扩展应用程序并提供可靠的服务,你需要了解应用程序在部署时的行为。
28-
你可以通过检测容器检查 Kubernetes 集群中的应用程序性能,
29-
[Pod](/zh-cn/docs/concepts/workloads/pods)
30-
[服务](/zh-cn/docs/concepts/services-networking/service/)和整个集群的特征
28+
你可以通过检测容器、[Pod](/zh-cn/docs/concepts/workloads/pods)
29+
[Service](/zh-cn/docs/concepts/services-networking/service/)
30+
和整个集群的特征来检查 Kubernetes 集群中应用程序的性能
3131
Kubernetes 在每个级别上提供有关应用程序资源使用情况的详细信息。
3232
此信息使你可以评估应用程序的性能,以及在何处可以消除瓶颈以提高整体性能。
3333

@@ -50,16 +50,16 @@ cluster components such as the
5050
controller, as well as the `kubectl top` utility.
5151
These metrics are collected by the lightweight, short-term, in-memory
5252
[metrics-server](https://github.com/kubernetes-sigs/metrics-server) and
53-
are exposed via the `metrics.k8s.io` API.
53+
are exposed via the `metrics.k8s.io` API.
5454
-->
5555
## 资源度量管道 {#resource-metrics-pipeline}
5656

5757
资源指标管道提供了一组与集群组件,例如
5858
[Horizontal Pod Autoscaler](/zh-cn/docs/tasks/run-application/horizontal-pod-autoscale/)
5959
控制器以及 `kubectl top` 实用程序相关的有限度量。
6060
这些指标是由轻量级的、短期、内存存储的
61-
[metrics-server](https://github.com/kubernetes-sigs/metrics-server) 收集的
62-
通过 `metrics.k8s.io` 公开。
61+
[metrics-server](https://github.com/kubernetes-sigs/metrics-server) 收集
62+
并通过 `metrics.k8s.io` 公开。
6363

6464
<!--
6565
metrics-server discovers all nodes on the cluster and
@@ -78,10 +78,10 @@ resource usage statistics through the metrics-server Resource Metrics API.
7878
This API is served at `/metrics/resource/v1beta1` on the kubelet's authenticated and
7979
read-only ports.
8080
-->
81-
度量服务器发现集群中的所有节点,并且查询每个节点的
81+
metrics-server 发现集群中的所有节点,并且查询每个节点的
8282
[kubelet](/zh-cn/docs/reference/command-line-tools-reference/kubelet/)
8383
以获取 CPU 和内存使用情况。
84-
Kubelet 充当 Kubernetes 主节点与节点之间的桥梁,管理机器上运行的 Pod 和容器。
84+
kubelet 充当 Kubernetes 主节点与节点之间的桥梁,管理机器上运行的 Pod 和容器。
8585
kubelet 将每个 Pod 转换为其组成的容器,并通过容器运行时接口从容器运行时获取各个容器使用情况统计信息。
8686
如果某个容器运行时使用 Linux cgroups 和名字空间来实现容器。
8787
并且这一容器运行时不发布资源用量统计信息,

0 commit comments

Comments
 (0)