Skip to content

Commit ada3dab

Browse files
authored
添加vip支持aap功能介绍 (#135)
* 添加vip支持aap功能介绍 Signed-off-by: zcq98 <[email protected]> * add vip support aap english doc Signed-off-by: zcq98 <[email protected]> * aap support multiple interface Signed-off-by: zcq98 <[email protected]> * fix lint issues Signed-off-by: zcq98 <[email protected]> --------- Signed-off-by: zcq98 <[email protected]> Co-authored-by: zcq98 <[email protected]>
1 parent 6413cd8 commit ada3dab

File tree

2 files changed

+224
-0
lines changed

2 files changed

+224
-0
lines changed

docs/advance/vip.en.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ In some scenarios we want to dynamically reserve part of the IP but not assign i
55
- Kubernetes nested Kubernetes scenarios where the upper Kubernetes uses the Underlay network take up the available addresses of the underlying Subnet.
66
- LB or other network infrastructure requires the use of an IP within a Subnet.
77

8+
In addition, VIP can also reserve IP for Allowed-Address-Pairs to support scenarios where a single network card is configured with multiple IPs, e.g:
9+
10+
- Keepalived can help achieve fast failover and flexible load balancing architecture by configuring additional IP address pairs.
11+
812
## Create Random Address VIP
913

1014
If you just want to set aside a number of IPs and have no requirement for the IP addresses themselves, you can use the following yaml to create them:
@@ -59,8 +63,126 @@ static-vip01 10.16.0.121 00:00:00:F0:DB:26 o
5963

6064
It can be seen that the VIP has been assigned the expected IP address.
6165

66+
## Pod uses VIP to bind IP
67+
68+
> This feature is supported starting from v1.12.
69+
70+
You can use annotation to assign a VIP to a Pod:
71+
72+
```yaml
73+
apiVersion: v1
74+
kind: Pod
75+
metadata:
76+
name: static-ip
77+
annotations:
78+
ovn.kubernetes.io/vip: vip-dynamic-01 # Specify vip
79+
namespace: default
80+
spec:
81+
containers:
82+
- name: static-ip
83+
image: docker.io/library/nginx:alpine
84+
```
85+
6286
## StatefulSet & Kubevirt VM keep VIP
6387

6488
Specify for `StatefulSet` and `VM` resources, these Pods their owned will reuse the VIP when these Pods recreating.
6589

6690
VM keep VIP must be enable the `keep-vm-ip` param in `kube-ovn-controller`. Refer [Kubevirt VM Fixed Address Settings](../guide/setup-options.en.md#kubevirt-vm)
91+
92+
## Create VIP to support AAP
93+
94+
```yaml
95+
apiVersion: kubeovn.io/v1
96+
kind: Vip
97+
metadata:
98+
name: vip-aap
99+
spec:
100+
subnet: ovn-default
101+
namespace: default
102+
selector:
103+
- "app: aap1"
104+
```
105+
106+
VIP also supports the allocation of fixed addresses and random addresses, and the allocation method is as described above.
107+
108+
- `namespace`: In the AAP scenario, VIP needs to explicitly specify the namespace. VIP only allows resources in the same namespace to enable the AAP function.
109+
- `selector`: In the AAP scenario, the node selector used to select the Pod attached to the vip has the same format as the NodeSelector in Kubernetes.
110+
111+
Query the Port corresponding to the VIP after creation:
112+
113+
```yaml
114+
# kubectl ko nbctl show ovn-default
115+
switch e32e1d3b-c539-45f4-ab19-be4e33a061f6 (ovn-default)
116+
port aap-vip
117+
type: virtual
118+
```
119+
120+
## Pod uses VIP to enable AAP
121+
122+
You can use annotation to specify a VIP to enable the AAP function, and labels need to meet the conditions of the node selector in the VIP.
123+
124+
Pod supports specifying multiple VIPs, with a configuration format of: ovn.kubernetes.io/aaps: vip-aap,vip-aap2,vip-aap3
125+
126+
The AAP function supports [multiple interfaces] (./multi-nic.en.md). If the Pod is configured with multiple interfaces, AAP will configure the corresponding Port in the same subnet of the Pod and the VIP.
127+
128+
```yaml
129+
apiVersion: v1
130+
kind: Pod
131+
metadata:
132+
name: busybox
133+
annotations:
134+
ovn.kubernetes.io/aaps: vip-aap
135+
labels:
136+
app: aap1
137+
spec:
138+
containers:
139+
- name: busybox
140+
image: busybox
141+
command: ["sleep", "3600"]
142+
securityContext:
143+
capabilities:
144+
add:
145+
- NET_ADMIN
146+
```
147+
148+
Query the configuration corresponding to the AAP after creation:
149+
150+
```bash
151+
# kubectl ko nbctl list logical_switch_port aap-vip
152+
_uuid : cd930750-0533-4f06-a6c0-217ddac73272
153+
addresses : []
154+
dhcpv4_options : []
155+
dhcpv6_options : []
156+
dynamic_addresses : []
157+
enabled : []
158+
external_ids : {ls=ovn-default, vendor=kube-ovn}
159+
ha_chassis_group : []
160+
mirror_rules : []
161+
name : aap-vip
162+
options : {virtual-ip="10.16.0.100", virtual-parents="busybox.default"}
163+
parent_name : []
164+
port_security : []
165+
tag : []
166+
tag_request : []
167+
type : virtual
168+
up : false
169+
```
170+
171+
Virtual ip is configured as an IP reserved for VIP, while virtual parents are configured as the port corresponding to the pod that enables AAP function.
172+
173+
Query the configuration corresponding to the Pod after creation:
174+
175+
```bash
176+
# kubectl exec -it busybox -- ip addr add 10.16.0.100/16 dev eth0
177+
# kubectl exec -it busybox01 -- ip addr show eth0
178+
35: eth0@if36: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1400 qdisc noqueue
179+
link/ether 00:00:00:e2:ab:0c brd ff:ff:ff:ff:ff:ff
180+
inet 10.16.0.7/16 brd 10.16.255.255 scope global eth0
181+
valid_lft forever preferred_lft forever
182+
inet 10.16.0.100/16 scope global secondary eth0
183+
valid_lft forever preferred_lft forever
184+
inet6 fe80::200:ff:fee2:ab0c/64 scope link
185+
valid_lft forever preferred_lft forever
186+
```
187+
188+
In addition to the IP automatically assigned during Pod creation, the VIP IP has also been successfully bound, and other Pods within the current subnet can communicate with these two IPs.

docs/advance/vip.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
- Kubernetes 嵌套 Kubernetes 的场景中上层 Kubernetes 使用 Underlay 网络会占用底层 Subnet 可用地址。
66
- LB 或其他网络基础设施需要使用一个 Subnet 内的 IP,但不会单独起 Pod。
77

8+
此外,VIP 还可以为 Allowed-Address-Pairs 预留 IP 用来支持单个网卡配置多个 IP 的场景,例如:
9+
10+
- Keepalived 通过配置额外的 IP 地址对,可以帮助实现快速故障切换和灵活的负载均衡架构
11+
812
## 创建随机地址 VIP
913

1014
如果只是为了预留若干 IP 而对 IP 地址本身没有要求可以使用下面的 yaml 进行创建:
@@ -84,3 +88,101 @@ spec:
8488
针对 `StatefulSet` 和 `VM` 的特殊性,在他们的 Pod 销毁再拉起起后会重新使用之前设置的 VIP。
8589

8690
VM 保留 VIP 需要确保 `kube-ovn-controller` 的 `keep-vm-ip` 参数为 `true`。请参考 [Kubevirt VM 固定地址开启设置](../guide/setup-options.md#kubevirt-vm)
91+
92+
## 创建 VIP 支持 AAP
93+
94+
```yaml
95+
apiVersion: kubeovn.io/v1
96+
kind: Vip
97+
metadata:
98+
name: vip-aap
99+
spec:
100+
subnet: ovn-default
101+
namespace: default
102+
selector:
103+
- "app: aap1"
104+
```
105+
106+
VIP 同样支持固定地址和随机地址的分配,分配方式如上文所述。
107+
108+
- `namespace`: AAP 场景下,VIP 需显式地指定命名空间,VIP 仅允许相同命名空间的资源开启 AAP 功能。
109+
- `selector`: AAP 场景下,用于选择 VIP 所附属的 Pod 的节点选择器,格式和 Kubernetes 中的 NodeSelector 格式相同。
110+
111+
创建成功后查询该 VIP 对应的 Port:
112+
113+
```bash
114+
# kubectl ko nbctl show ovn-default
115+
switch e32e1d3b-c539-45f4-ab19-be4e33a061f6 (ovn-default)
116+
port aap-vip
117+
type: virtual
118+
```
119+
120+
## Pod 使用 VIP 开启 AAP
121+
122+
可以使用 annotation 指定 VIP 开启 AAP 功能,labels 需要满足 VIP 中节点选择器的条件。
123+
124+
Pod 支持指定多个 VIP,配置格式为:ovn.kubernetes.io/aaps: vip-aap,vip-aap2,vip-aap3
125+
126+
AAP 功能支持[多网卡场景](./multi-nic.md),若 Pod 配置了多网卡,AAP 会对 Pod 中和 VIP 同一 subnet 的对应 Port 进行配置
127+
128+
```yaml
129+
apiVersion: v1
130+
kind: Pod
131+
metadata:
132+
name: busybox
133+
annotations:
134+
ovn.kubernetes.io/aaps: vip-aap
135+
labels:
136+
app: aap1
137+
spec:
138+
containers:
139+
- name: busybox
140+
image: busybox
141+
command: ["sleep", "3600"]
142+
securityContext:
143+
capabilities:
144+
add:
145+
- NET_ADMIN
146+
```
147+
148+
创建成功后查询该 AAP 对应的配置:
149+
150+
```bash
151+
# kubectl ko nbctl list logical_switch_port aap-vip
152+
_uuid : cd930750-0533-4f06-a6c0-217ddac73272
153+
addresses : []
154+
dhcpv4_options : []
155+
dhcpv6_options : []
156+
dynamic_addresses : []
157+
enabled : []
158+
external_ids : {ls=ovn-default, vendor=kube-ovn}
159+
ha_chassis_group : []
160+
mirror_rules : []
161+
name : aap-vip
162+
options : {virtual-ip="10.16.0.100", virtual-parents="busybox.default"}
163+
parent_name : []
164+
port_security : []
165+
tag : []
166+
tag_request : []
167+
type : virtual
168+
up : false
169+
```
170+
171+
virtual-ip 被配置为 VIP 预留的 IP,virtual-parents 配置为开启 AAP 功能的 Pod 对应的 Port。
172+
173+
创建成功后查询该 Pod 对应的配置:
174+
175+
```bash
176+
# kubectl exec -it busybox -- ip addr add 10.16.0.100/16 dev eth0
177+
# kubectl exec -it busybox01 -- ip addr show eth0
178+
35: eth0@if36: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1400 qdisc noqueue
179+
link/ether 00:00:00:e2:ab:0c brd ff:ff:ff:ff:ff:ff
180+
inet 10.16.0.7/16 brd 10.16.255.255 scope global eth0
181+
valid_lft forever preferred_lft forever
182+
inet 10.16.0.100/16 scope global secondary eth0
183+
valid_lft forever preferred_lft forever
184+
inet6 fe80::200:ff:fee2:ab0c/64 scope link
185+
valid_lft forever preferred_lft forever
186+
```
187+
188+
除 Pod 创建时自动分配的 IP,VIP 的 IP 也被成功绑定,并且当前 subnet 内的其它 Pod 能和这两个 IP 进行通信。

0 commit comments

Comments
 (0)