Skip to content

Commit 515cd45

Browse files
authored
Merge pull request #41596 from windsonsea/ipmasq
[zh] sync developing-cloud-controller-manager, ip-masq-agent, and guaranteed-scheduling-pods
2 parents 2ee8d0a + dfafd55 commit 515cd45

File tree

3 files changed

+75
-31
lines changed

3 files changed

+75
-31
lines changed

content/zh-cn/docs/tasks/administer-cluster/developing-cloud-controller-manager.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ title: 开发云控制器管理器
33
content_type: task
44
weight: 190
55
---
6-
76
<!--
87
reviewers:
98
- luxas
@@ -27,7 +26,7 @@ weight: 190
2726
2827
Since cloud providers develop and release at a different pace compared to the Kubernetes project, abstracting the provider-specific code to the `cloud-controller-manager` binary allows cloud vendors to evolve independently from the core Kubernetes code.
2928
-->
30-
## 背景
29+
## 背景 {#background}
3130

3231
由于云驱动的开发和发布与 Kubernetes 项目本身步调不同,将特定于云环境的代码抽象到
3332
`cloud-controller-manager` 二进制组件有助于云厂商独立于 Kubernetes
@@ -45,7 +44,7 @@ Kubernetes 核心代码导入软件包来实现一个 cloud-controller-manager
4544
<!--
4645
## Developing
4746
-->
48-
## 开发
47+
## 开发 {#developing}
4948

5049
### 树外(Out of Tree)
5150

@@ -84,4 +83,3 @@ For in-tree cloud providers, you can run the in-tree cloud controller manager as
8483
对于树内(In-Tree)驱动,你可以将树内云控制器管理器作为集群中的
8584
{{< glossary_tooltip term_id="daemonset" text="DaemonSet" >}} 来运行。
8685
有关详细信息,请参阅[云控制器管理器管理](/zh-cn/docs/tasks/administer-cluster/running-cloud-controller/)
87-

content/zh-cn/docs/tasks/administer-cluster/guaranteed-scheduling-critical-addon-pods.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@ title: 关键插件 Pod 的调度保证
33
content_type: concept
44
weight: 220
55
---
6+
<!--
7+
reviewers:
8+
- davidopp
9+
- filipg
10+
- piosz
11+
title: Guaranteed Scheduling For Critical Add-On Pods
12+
content_type: concept
13+
weight: 220
14+
-->
615

716
<!-- overview -->
817

918
<!--
10-
Kubernetes core components such as the API server, scheduler, and controller-manager run on a control plane node.
11-
However, add-ons must run on a regular cluster node.
19+
Kubernetes core components such as the API server, scheduler, and controller-manager run on a control plane node. However, add-ons must run on a regular cluster node.
1220
Some of these add-ons are critical to a fully functional cluster, such as metrics-server, DNS, and UI.
1321
A cluster may stop working properly if a critical add-on is evicted (either manually or as a side effect of another operation like upgrade)
1422
and becomes pending (for example when the cluster is highly utilized and either there are other pending pods that schedule into the space
@@ -18,7 +26,8 @@ Kubernetes 核心组件(如 API 服务器、调度器、控制器管理器)
1826
但是插件必须在常规集群节点上运行。
1927
其中一些插件对于功能完备的集群至关重要,例如 Heapster、DNS 和 UI。
2028
如果关键插件被逐出(手动或作为升级等其他操作的副作用)或者变成挂起状态,集群可能会停止正常工作。
21-
关键插件进入挂起状态的例子有:集群利用率过高;被逐出的关键插件 Pod 释放了空间,但该空间被之前悬决的 Pod 占用;由于其它原因导致节点上可用资源的总量发生变化。
29+
关键插件进入挂起状态的例子有:集群利用率过高;被逐出的关键插件 Pod 释放了空间,但该空间被之前悬决的
30+
Pod 占用;由于其它原因导致节点上可用资源的总量发生变化。
2231

2332
<!--
2433
Note that marking a pod as critical is not meant to prevent evictions entirely; it only prevents the pod from becoming permanently unavailable.
@@ -35,9 +44,7 @@ A static pod marked as critical, can't be evicted. However, a non-static pods ma
3544
### 标记关键 Pod
3645

3746
<!--
38-
To mark a Pod as critical, set priorityClassName for that Pod to `system-cluster-critical` or `system-node-critical`. `system-node-critical` is the highest available priority, even higher than `system-cluster-critical`
47+
To mark a Pod as critical, set priorityClassName for that Pod to `system-cluster-critical` or `system-node-critical`. `system-node-critical` is the highest available priority, even higher than `system-cluster-critical`.
3948
-->
4049
要将 Pod 标记为关键性(critical),设置 Pod 的 priorityClassName 为 `system-cluster-critical` 或者 `system-node-critical`
4150
`system-node-critical` 是最高级别的可用性优先级,甚至比 `system-cluster-critical` 更高。
42-
43-

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

Lines changed: 60 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ This page shows how to configure and enable the `ip-masq-agent`.
2323
<!--
2424
## IP Masquerade Agent User Guide
2525
-->
26-
## IP Masquerade Agent 用户指南
26+
## IP Masquerade Agent 用户指南 {#ip-masquerade-agent-user-guide}
2727

2828
<!--
29-
The `ip-masq-agent` configures iptables rules to hide a pod's IP address behind the cluster node's IP address. This is typically done when sending traffic to destinations outside the cluster's pod [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) range.
29+
The `ip-masq-agent` configures iptables rules to hide a pod's IP address behind the cluster
30+
node's IP address. This is typically done when sending traffic to destinations outside the
31+
cluster's pod [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) range.
3032
-->
3133
`ip-masq-agent` 配置 iptables 规则以隐藏位于集群节点 IP 地址后面的 Pod 的 IP 地址。
3234
这通常在将流量发送到集群的 Pod
@@ -36,19 +38,22 @@ The `ip-masq-agent` configures iptables rules to hide a pod's IP address behind
3638
<!--
3739
### **Key Terms**
3840
-->
39-
### **关键术语**
41+
### **关键术语** {#key-terms}
4042

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

4952
<!--
5053
* **Masquerading**
51-
A form of NAT that is typically used to perform a many to one address translation, where multiple source IP addresses are masked behind a single address, which is typically the device doing the IP routing. In Kubernetes this is the Node's IP address.
54+
A form of NAT that is typically used to perform a many to one address translation, where
55+
multiple source IP addresses are masked behind a single address, which is typically the
56+
device doing the IP routing. In Kubernetes this is the Node's IP address.
5257
-->
5358
* **伪装**
5459
NAT 的一种形式,通常用于执行多对一地址转换,其中多个源 IP 地址被隐藏在
@@ -57,7 +62,10 @@ The `ip-masq-agent` configures iptables rules to hide a pod's IP address behind
5762

5863
<!--
5964
* **CIDR (Classless Inter-Domain Routing)**
60-
Based on the variable-length subnet masking, allows specifying arbitrary-length prefixes. CIDR introduced a new method of representation for IP addresses, now commonly known as **CIDR notation**, in which an address or routing prefix is written with a suffix indicating the number of bits of the prefix, such as 192.168.2.0/24.
65+
Based on the variable-length subnet masking, allows specifying arbitrary-length prefixes.
66+
CIDR introduced a new method of representation for IP addresses, now commonly known as
67+
**CIDR notation**, in which an address or routing prefix is written with a suffix indicating
68+
the number of bits of the prefix, such as 192.168.2.0/24.
6169
-->
6270
* **CIDR (无类别域间路由)**
6371
基于可变长度子网掩码,允许指定任意长度的前缀。
@@ -66,14 +74,29 @@ The `ip-masq-agent` configures iptables rules to hide a pod's IP address behind
6674

6775
<!--
6876
* **Link Local**
69-
A link-local address is a network address that is valid only for communications within the network segment or the broadcast domain that the host is connected to. Link-local addresses for IPv4 are defined in the address block 169.254.0.0/16 in CIDR notation.
77+
A link-local address is a network address that is valid only for communications within the
78+
network segment or the broadcast domain that the host is connected to. Link-local addresses
79+
for IPv4 are defined in the address block 169.254.0.0/16 in CIDR notation.
7080
-->
7181
* **本地链路**
7282
本地链路是仅对网段或主机所连接的广播域内的通信有效的网络地址。
7383
IPv4 的本地链路地址在 CIDR 表示法的地址块 169.254.0.0/16 中定义。
7484

7585
<!--
76-
The ip-masq-agent configures iptables rules to handle masquerading node/pod IP addresses when sending traffic to destinations outside the cluster node's IP and the Cluster IP range. This essentially hides pod IP addresses behind the cluster node's IP address. In some environments, traffic to "external" addresses must come from a known machine address. For example, in Google Cloud, any traffic to the internet must come from a VM's IP. When containers are used, as in Google Kubernetes Engine, the Pod IP will be rejected for egress. To avoid this, we must hide the Pod IP behind the VM's own IP address - generally known as "masquerade". By default, the agent is configured to treat the three private IP ranges specified by [RFC 1918](https://tools.ietf.org/html/rfc1918) as non-masquerade [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing). These ranges are 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. The agent will also treat link-local (169.254.0.0/16) as a non-masquerade CIDR by default. The agent is configured to reload its configuration from the location */etc/config/ip-masq-agent* every 60 seconds, which is also configurable.
86+
The ip-masq-agent configures iptables rules to handle masquerading node/pod IP addresses when
87+
sending traffic to destinations outside the cluster node's IP and the Cluster IP range. This
88+
essentially hides pod IP addresses behind the cluster node's IP address. In some environments,
89+
traffic to "external" addresses must come from a known machine address. For example, in Google
90+
Cloud, any traffic to the internet must come from a VM's IP. When containers are used, as in
91+
Google Kubernetes Engine, the Pod IP will be rejected for egress. To avoid this, we must hide
92+
the Pod IP behind the VM's own IP address - generally known as "masquerade". By default, the
93+
agent is configured to treat the three private IP ranges specified by
94+
[RFC 1918](https://tools.ietf.org/html/rfc1918) as non-masquerade
95+
[CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing).
96+
These ranges are `10.0.0.0/8`, `172.16.0.0/12`, and `192.168.0.0 16`.
97+
The agent will also treat link-local (169.254.0.0/16) as a non-masquerade CIDR by default.
98+
The agent is configured to reload its configuration from the location
99+
*/etc/config/ip-masq-agent* every 60 seconds, which is also configurable.
77100
-->
78101
ip-masq-agent 配置 iptables 规则,以便在将流量发送到集群节点的 IP 和集群 IP 范围之外的目标时
79102
处理伪装节点或 Pod 的 IP 地址。这本质上隐藏了集群节点 IP 地址后面的 Pod IP 地址。
@@ -93,13 +116,15 @@ ip-masq-agent 配置 iptables 规则,以便在将流量发送到集群节点
93116
![masq/non-masq example](/images/docs/ip-masq.png)
94117

95118
<!--
96-
The agent configuration file must be written in YAML or JSON syntax, and may contain three optional keys:
119+
The agent configuration file must be written in YAML or JSON syntax, and may contain three
120+
optional keys:
97121
-->
98122
代理配置文件必须使用 YAML 或 JSON 语法编写,并且可能包含三个可选值:
99123

100124
<!--
101125
* `nonMasqueradeCIDRs`: A list of strings in
102-
[CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) notation that specify the non-masquerade ranges.
126+
[CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) notation that specify
127+
the non-masquerade ranges.
103128
-->
104129
* `nonMasqueradeCIDRs`
105130
[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)
@@ -120,7 +145,11 @@ The agent configuration file must be written in YAML or JSON syntax, and may con
120145
例如 '30s',其中 's' 是秒,'ms' 是毫秒。
121146

122147
<!--
123-
Traffic to 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16) ranges will NOT be masqueraded. Any other traffic (assumed to be internet) will be masqueraded. An example of a local destination from a pod could be its Node's IP address as well as another node's address or one of the IP addresses in Cluster's IP range. Any other traffic will be masqueraded by default. The below entries show the default set of rules that are applied by the ip-masq-agent:
148+
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
150+
from a pod could be its Node's IP address as well as another node's address or one of the IP
151+
addresses in Cluster's IP range. Any other traffic will be masqueraded by default. The
152+
below entries show the default set of rules that are applied by the ip-masq-agent:
124153
-->
125154
10.0.0.0/8、172.16.0.0/12 和 192.168.0.0/16 范围内的流量不会被伪装。
126155
任何其他流量(假设是互联网)将被伪装。
@@ -132,12 +161,12 @@ iptables -t nat -L IP-MASQ-AGENT
132161
```
133162

134163
```none
164+
target prot opt source destination
135165
RETURN all -- anywhere 169.254.0.0/16 /* ip-masq-agent: cluster-local traffic should not be subject to MASQUERADE */ ADDRTYPE match dst-type !LOCAL
136166
RETURN all -- anywhere 10.0.0.0/8 /* ip-masq-agent: cluster-local traffic should not be subject to MASQUERADE */ ADDRTYPE match dst-type !LOCAL
137167
RETURN all -- anywhere 172.16.0.0/12 /* ip-masq-agent: cluster-local traffic should not be subject to MASQUERADE */ ADDRTYPE match dst-type !LOCAL
138168
RETURN all -- anywhere 192.168.0.0/16 /* ip-masq-agent: cluster-local traffic should not be subject to MASQUERADE */ ADDRTYPE match dst-type !LOCAL
139169
MASQUERADE all -- anywhere anywhere /* ip-masq-agent: outbound traffic should be subject to MASQUERADE (this match must come after cluster-local CIDR matches) */ ADDRTYPE match dst-type !LOCAL
140-
141170
```
142171

143172
<!--
@@ -159,7 +188,7 @@ to your cluster.
159188
## Create an ip-masq-agent
160189
To create an ip-masq-agent, run the following kubectl command:
161190
-->
162-
## 创建 ip-masq-agent
191+
## 创建 ip-masq-agent {#create-ip-masq-agent}
163192

164193
通过运行以下 kubectl 指令创建 ip-masq-agent:
165194

@@ -168,7 +197,8 @@ kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/ip-masq-agent
168197
```
169198

170199
<!--
171-
You must also apply the appropriate node label to any nodes in your cluster that you want the agent to run on.
200+
You must also apply the appropriate node label to any nodes in your cluster that you want the
201+
agent to run on.
172202
-->
173203
你必须同时将适当的节点标签应用于集群中希望代理运行的任何节点。
174204

@@ -179,10 +209,16 @@ kubectl label nodes my-node node.kubernetes.io/masq-agent-ds-ready=true
179209
<!--
180210
More information can be found in the ip-masq-agent documentation [here](https://github.com/kubernetes-sigs/ip-masq-agent)
181211
-->
182-
更多信息可以通过 ip-masq-agent 文档 [这里](https://github.com/kubernetes-sigs/ip-masq-agent) 找到。
212+
更多信息可以通过 ip-masq-agent 文档[这里](https://github.com/kubernetes-sigs/ip-masq-agent)找到。
183213

184214
<!--
185-
In most cases, the default set of rules should be sufficient; however, if this is not the case for your cluster, you can create and apply a [ConfigMap](/docs/tasks/configure-pod-container/configure-pod-configmap/) to customize the IP ranges that are affected. For example, to allow only 10.0.0.0/8 to be considered by the ip-masq-agent, you can create the following [ConfigMap](/docs/tasks/configure-pod-container/configure-pod-configmap/) in a file called "config".
215+
In most cases, the default set of rules should be sufficient; however, if this is not the case
216+
for your cluster, you can create and apply a
217+
[ConfigMap](/docs/tasks/configure-pod-container/configure-pod-configmap/) to customize the IP
218+
ranges that are affected. For example, to allow
219+
only 10.0.0.0/8 to be considered by the ip-masq-agent, you can create the following
220+
[ConfigMap](/docs/tasks/configure-pod-container/configure-pod-configmap/) in a file called
221+
"config".
186222
-->
187223
在大多数情况下,默认的规则集应该足够;但是,如果你的集群不是这种情况,则可以创建并应用
188224
[ConfigMap](/zh-cn/docs/tasks/configure-pod-container/configure-pod-configmap/)
@@ -192,7 +228,8 @@ In most cases, the default set of rules should be sufficient; however, if this i
192228

193229
{{< note >}}
194230
<!--
195-
It is important that the file is called config since, by default, that will be used as the key for lookup by the `ip-masq-agent`:
231+
It is important that the file is called config since, by default, that will be used as the key
232+
for lookup by the `ip-masq-agent`:
196233
-->
197234
重要的是,该文件之所以被称为 config,因为默认情况下,该文件将被用作
198235
`ip-masq-agent` 查找的主键:
@@ -214,7 +251,8 @@ kubectl create configmap ip-masq-agent --from-file=config --namespace=kube-syste
214251
```
215252

216253
<!--
217-
This will update a file located at `/etc/config/ip-masq-agent` which is periodically checked every `resyncInterval` and applied to the cluster node.
254+
This will update a file located at `/etc/config/ip-masq-agent` which is periodically checked
255+
every `resyncInterval` and applied to the cluster node.
218256
After the resync interval has expired, you should see the iptables rules reflect your changes:
219257
-->
220258
这将更新位于 `/etc/config/ip-masq-agent` 的一个文件,该文件以 `resyncInterval`
@@ -234,7 +272,9 @@ MASQUERADE all -- anywhere anywhere /* ip-masq-agent:
234272
```
235273

236274
<!--
237-
By default, the link local range (169.254.0.0/16) is also handled by the ip-masq agent, which sets up the appropriate iptables rules. To have the ip-masq-agent ignore link local, you can set `masqLinkLocal` to true in the ConfigMap.
275+
By default, the link local range (169.254.0.0/16) is also handled by the ip-masq agent, which
276+
sets up the appropriate iptables rules. To have the ip-masq-agent ignore link local, you can
277+
set `masqLinkLocal` to true in the ConfigMap.
238278
-->
239279
默认情况下,本地链路范围 (169.254.0.0/16) 也由 ip-masq agent 处理,
240280
该代理设置适当的 iptables 规则。 要使 ip-masq-agent 忽略本地链路,
@@ -246,4 +286,3 @@ nonMasqueradeCIDRs:
246286
resyncInterval: 60s
247287
masqLinkLocal: true
248288
```
249-

0 commit comments

Comments
 (0)