Skip to content

Commit a79e8ed

Browse files
authored
添加自定义vpc额外公网网卡功能介绍 (#134)
* 添加自定义vpc额外公网网卡功能介绍 Signed-off-by: zcq98 <[email protected]> * add ovn-eip-fip-snat english doc Signed-off-by: zcq98 <[email protected]> --------- Signed-off-by: zcq98 <[email protected]> Co-authored-by: zcq98 <[email protected]>
1 parent ecb90cb commit a79e8ed

File tree

2 files changed

+202
-3
lines changed

2 files changed

+202
-3
lines changed

docs/advance/ovn-eip-fip-snat.en.md

Lines changed: 101 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ The CRD supported by this function is basically the same as the iptable nat gw p
3636

3737
## 1. Deployment
3838

39-
Currently allows all vpcs to share the same provider vlan subnet resources, similar to neutron ovn mode.
40-
Compatible with previous scenarios [default VPC EIP/SNAT](../guide/eip-snat.en.md).
39+
Currently allows all vpcs to share the same default provider vlan subnet resources, custom vpcs support extending provider vlan subnet to enable the use of multiple public networks. similar to neutron ovn mode. Compatible with previous scenarios [default VPC EIP/SNAT](../guide/eip-snat.en.md).
4140

4241
During the deployment phase, you may need to specify a default public network logical switch based on actual conditions.
4342
If no vlan is in use (vlan 0 is used), the following startup parameters do not need to be configured.
@@ -130,6 +129,13 @@ Of course, you can also manually create the lrp type ovn eip in advance.
130129

131130
### 1.3 Custom vpc enable eip snat fip function
132131

132+
Clusters generally require multiple gateway nodes to achieve high availability. The configuration is as follows:
133+
134+
```bash
135+
# First specify external-gw-nodes by adding label
136+
kubectl label nodes pc-node-1 pc-node-2 pc-node-3 ovn.kubernetes.io/external-gw=true
137+
```
138+
133139
``` bash
134140
# cat 00-ns.yml
135141

@@ -202,6 +208,91 @@ Route Table <main>:
202208
# The route currently supports automatic maintenance
203209
```
204210

211+
### 1.4 Use additional public network
212+
213+
#### 1.4.1 Create additional underlay public network
214+
215+
Additional public network functions will be enabled after the default eip snat fip function is enabled. If there is only 1 public network card, please use the default eip snat fip function.
216+
217+
```yaml
218+
# provider-network, vlan, subnet
219+
# cat 01-extra-provider-network.yaml
220+
apiVersion: kubeovn.io/v1
221+
kind: ProviderNetwork
222+
metadata:
223+
name: extra
224+
spec:
225+
defaultInterface: vlan
226+
# cat 02-extra-vlan.yaml
227+
apiVersion: kubeovn.io/v1
228+
kind: Vlan
229+
metadata:
230+
name: vlan0
231+
spec:
232+
id: 0
233+
provider: extra
234+
# cat 03-extra-vlan-subnet.yaml
235+
apiVersion: kubeovn.io/v1
236+
kind: Subnet
237+
metadata:
238+
name: extra
239+
spec:
240+
protocol: IPv4
241+
cidrBlock: 10.10.204.0/24
242+
gateway: 10.10.204.254
243+
vlan: vlan0
244+
excludeIps:
245+
- 10.10.204.1..10.10.204.100
246+
```
247+
248+
#### 1.4.2 Custom vpc configuration
249+
250+
```yaml
251+
apiVersion: kubeovn.io/v1
252+
kind: Vpc
253+
metadata:
254+
name: vpc1
255+
spec:
256+
namespaces:
257+
- vpc1
258+
staticRoutes: # configure routing rules: Which additional public network routes a subnet under the vpc needs to be based on needs to be added manually. The following example is for reference only. Users need to configure it according to their actual situation.
259+
- cidr: 192.168.0.1/28
260+
nextHopIP: 10.10.204.254
261+
policy: policySrc
262+
enableExternal: true # vpc enableExternal will automatically create an lrp association to the public network specified above
263+
addExternalSubnets: # configure addExternalSubnets to support connecting multiple additional public networks
264+
- extra
265+
```
266+
267+
After the above template is applied, you should see the following resources exist
268+
269+
```yaml
270+
# k ko nbctl show vpc1
271+
router 87ad06fd-71d5-4ff8-a1f0-54fa3bba1a7f (vpc1)
272+
port vpc1-vpc1-subnet1
273+
mac: "00:00:00:ED:8E:C7"
274+
networks: ["192.168.0.1/24"]
275+
port vpc1-external204
276+
mac: "00:00:00:EF:05:C7"
277+
networks: ["10.5.204.105/24"]
278+
gateway chassis: [7cedd14f-265b-42e5-ac17-e03e7a1f2342 276baccb-fe9c-4476-b41d-05872a94976d fd9f140c-c45d-43db-a6c0-0d4f8ea298dd]
279+
port vpc1-extra
280+
mac: "00:00:00:EF:6A:C7"
281+
networks: ["10.10.204.105/24"]
282+
gateway chassis: [7cedd14f-265b-42e5-ac17-e03e7a1f2342 276baccb-fe9c-4476-b41d-05872a94976d fd9f140c-c45d-43db-a6c0-0d4f8ea298dd]
283+
```
284+
285+
```bash
286+
# k ko nbctl lr-route-list vpc1
287+
IPv4 Routes
288+
Route Table <main>:
289+
192.168.0.1/28 10.10.204.254 src-ip
290+
0.0.0.0/0 10.5.204.254 dst-ip
291+
# The route currently supports automatic maintenance
292+
# Additional public networks require manual routing configuration in the vpc. In the above example, the source IP address is 192.168.0.1/28 and will be forwarded to the additional public network.
293+
# Users can manually configure routing rules according to the situation
294+
```
295+
205296
## 2. ovn-eip
206297

207298
This function is designed and used in the same way as iptables-eip, ovn-eip currently has three types
@@ -224,6 +315,8 @@ spec:
224315
# Dynamically allocate an eip resource that is reserved for fip dnat_and_snat scenarios
225316
```
226317

318+
When an additional public network is configured, you can specify the public network that needs to be expanded through externalSubnet. In the above configuration, external204 and extra are optional.
319+
227320
### 2.1 Create an fip for pod
228321

229322
``` bash
@@ -450,6 +543,8 @@ spec:
450543

451544
```
452545

546+
When an additional public network is configured, you can specify the public network that needs to be expanded through externalSubnet. In the above configuration, external204 and extra are optional.
547+
453548
### 3.2 ovn-snat corresponds to a pod IP
454549

455550
This feature is designed and used in much the same way as iptables-snat
@@ -488,6 +583,8 @@ spec:
488583

489584
```
490585

586+
When an additional public network is configured, you can specify the public network that needs to be expanded through externalSubnet. In the above configuration, external204 and extra are optional.
587+
491588
After the above resources are created, you can see the following resources that the snat public network feature depends on.
492589

493590
``` bash
@@ -613,6 +710,8 @@ spec:
613710

614711
```
615712

713+
When an additional public network is configured, you can specify the public network that needs to be expanded through externalSubnet. In the above configuration, external204 and extra are optional.
714+
616715
The configuration of OvnDnatRule is similar to that of IptablesDnatRule.
617716

618717
```bash

docs/advance/ovn-eip-fip-snat.md

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Pod 基于分布式网关 FIP (dnat_and_snat) 出公网的大致流程,最后
3535

3636
## 1. 部署
3737

38-
目前允许所有(默认以及自定义)vpc 使用同一个 provider vlan subnet 资源,同时兼容[默认 VPC EIP/SNAT](../guide/eip-snat.md)的场景。
38+
目前允许所有(默认以及自定义) vpc 使用同一个默认 provider vlan subnet 资源,同时自定义 vpc 支持扩展 provider vlan subnet 从而实现使用多个公网,兼容[默认 VPC EIP/SNAT](../guide/eip-snat.md)的场景。
3939

4040
类似 neutron ovn,服务启动配置中需要指定 provider network 相关的配置,下述的启动参数也是为了兼容 VPC EIP/SNAT 的实现。
4141

@@ -125,6 +125,13 @@ data:
125125

126126
### 1.3 自定义 vpc 启用 eip snat fip 功能
127127

128+
集群一般需要多个网关 node 来实现高可用,配置如下:
129+
130+
```bash
131+
# 首先通过添加标签指定 external-gw-nodes
132+
kubectl label nodes pc-node-1 pc-node-2 pc-node-3 ovn.kubernetes.io/external-gw=true
133+
```
134+
128135
``` bash
129136
# cat 00-ns.yml
130137

@@ -199,6 +206,91 @@ Route Table <main>:
199206
# 目前该路由已自动维护
200207
```
201208

209+
### 1.4 使用额外的公网网络
210+
211+
#### 1.4.1 准备额外 underlay 公网网络
212+
213+
额外的公网网络功能在启动默认 eip snat fip 功能后才会启用,若只有 1 个公网网卡,请使用默认 eip snat fip 功能
214+
215+
```yaml
216+
# 准备 provider-network, vlan, subnet
217+
# cat 01-extra-provider-network.yaml
218+
apiVersion: kubeovn.io/v1
219+
kind: ProviderNetwork
220+
metadata:
221+
name: extra
222+
spec:
223+
defaultInterface: vlan
224+
# cat 02-extra-vlan.yaml
225+
apiVersion: kubeovn.io/v1
226+
kind: Vlan
227+
metadata:
228+
name: vlan0
229+
spec:
230+
id: 0
231+
provider: extra
232+
# cat 03-extra-vlan-subnet.yaml
233+
apiVersion: kubeovn.io/v1
234+
kind: Subnet
235+
metadata:
236+
name: extra
237+
spec:
238+
protocol: IPv4
239+
cidrBlock: 10.10.204.0/24
240+
gateway: 10.10.204.254
241+
vlan: vlan0
242+
excludeIps:
243+
- 10.10.204.1..10.10.204.100
244+
```
245+
246+
#### 1.4.2 自定义 vpc 配置
247+
248+
```yaml
249+
apiVersion: kubeovn.io/v1
250+
kind: Vpc
251+
metadata:
252+
name: vpc1
253+
spec:
254+
namespaces:
255+
- vpc1
256+
staticRoutes: # 配置路由规则:vpc下的某个子网需要基于哪一个额外的公网网络的路由需要手动添加,以下示例仅供参考,用户需根据自己的实际情况进行配置
257+
- cidr: 192.168.0.1/28
258+
nextHopIP: 10.10.204.254
259+
policy: policySrc
260+
enableExternal: true # 开启enableExternal后vpc会自动连接名为external的ls
261+
addExternalSubnets: # 配置addExternalSubnets支持连接多个额外的公网网络
262+
- extra
263+
```
264+
265+
以上模板应用后,应该可以看到如下资源存在
266+
267+
```bash
268+
# k ko nbctl show vpc1
269+
router 87ad06fd-71d5-4ff8-a1f0-54fa3bba1a7f (vpc1)
270+
port vpc1-vpc1-subnet1
271+
mac: "00:00:00:ED:8E:C7"
272+
networks: ["192.168.0.1/24"]
273+
port vpc1-external204
274+
mac: "00:00:00:EF:05:C7"
275+
networks: ["10.5.204.105/24"]
276+
gateway chassis: [7cedd14f-265b-42e5-ac17-e03e7a1f2342 276baccb-fe9c-4476-b41d-05872a94976d fd9f140c-c45d-43db-a6c0-0d4f8ea298dd]
277+
port vpc1-extra
278+
mac: "00:00:00:EF:6A:C7"
279+
networks: ["10.10.204.105/24"]
280+
gateway chassis: [7cedd14f-265b-42e5-ac17-e03e7a1f2342 276baccb-fe9c-4476-b41d-05872a94976d fd9f140c-c45d-43db-a6c0-0d4f8ea298dd]
281+
```
282+
283+
```bash
284+
# k ko nbctl lr-route-list vpc1
285+
IPv4 Routes
286+
Route Table <main>:
287+
192.168.0.1/28 10.10.204.254 src-ip
288+
0.0.0.0/0 10.5.204.254 dst-ip
289+
# 目前会为默认公网网络配置默认路由
290+
# 额外公网网络需要在vpc手动配置路由,上述实例中源IP地址为192.168.0.1/28会转发至额外公网网络
291+
# 用户可根据情况手动配置路由规则
292+
```
293+
202294
## 2. ovn-eip
203295

204296
该功能和 iptables-eip 设计和使用方式基本一致,ovn-eip 目前有三种 type
@@ -220,6 +312,8 @@ spec:
220312
# 动态分配一个 eip 资源,该资源预留用于 fip 场景
221313
```
222314

315+
当配置了额外公网网络时,可以通过 externalSubnet 指定需要扩展使用的公网网络,在上述配置中,可选 external204 和 extra 两个公网网络
316+
223317
### 2.1 ovn-fip 为 pod 绑定一个 fip
224318

225319
``` bash
@@ -443,6 +537,8 @@ spec:
443537

444538
```
445539

540+
当配置了额外公网网络时,可以通过 externalSubnet 指定需要扩展使用的公网网络,在上述配置中,可选 external204 和 extra 两个公网网络
541+
446542
### 3.2 ovn-snat 对应到一个 pod ip
447543

448544
该功能和 iptables-snat 设计和使用方式基本一致
@@ -482,6 +578,8 @@ spec:
482578

483579
```
484580

581+
当配置了额外公网网络时,可以通过 externalSubnet 指定需要扩展使用的公网网络,在上述配置中,可选 external204 和 extra 两个公网网络。
582+
485583
以上资源创建后,可以看到 snat 公网功能依赖的如下资源。
486584

487585
``` bash
@@ -608,6 +706,8 @@ spec:
608706

609707
```
610708

709+
当配置了额外公网网络时,可以通过 externalSubnet 指定需要扩展使用的公网网络,在上述配置中,可选 external204 和 extra 两个公网网络
710+
611711
OvnDnatRule 的配置与 IptablesDnatRule 类似
612712

613713
```bash

0 commit comments

Comments
 (0)