Skip to content

Commit 3a43a28

Browse files
authored
Merge pull request #660 from WillardHu/config-ipv6
CloudHub-EdgeHub Supports IPv6
2 parents 74af719 + d454c1d commit 3a43a28

File tree

2 files changed

+299
-0
lines changed

2 files changed

+299
-0
lines changed

docs/advanced/support_ipv6.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
title: CloudHub-EdgeHub Supports IPv6
3+
sidebar_position: 8
4+
---
5+
6+
## Abstract
7+
8+
With the surge of Internet of Things (IoT) devices and the increasing demand for real-time data processing, edge computing has emerged as a vital computing paradigm. Edge computing brings data processing and storage capabilities closer to the data sources and users by decentralizing them to the network's edge, effectively reducing latency and enhancing network performance. However, the traditional IPv4 protocol has many limitations in terms of address space, routing efficiency, and security, which cannot meet the growing needs of edge computing. IPv6, as the next-generation Internet protocol, offers vast address space, efficient routing mechanisms, and robust security, making it an ideal choice for edge computing.
9+
10+
11+
## Getting Started
12+
13+
### Cloud configuration
14+
15+
When EdgeCore uses the K8s native service to access CloudCore (Ingress or NodePort), the K8s cluster network needs to enable the IPv4/IPv6 dual-stack.
16+
17+
:::note
18+
If CloudCore uses hostNetwork mode to expose service, the K8s cluster does not need to enable dual-stack networking, and EdgeCore can access CloudCore through the IPv6 address + port of the node where CloudCore is located.
19+
:::
20+
21+
22+
#### Check IPv6 is enabled on the node
23+
24+
First, you need to make sure that IPv6 is enabled on the node. Use the command `ip -6 route show` to view IPv6 routing. If there is output, it means that it is supported. Otherwise, you need to configure /etc/sysctl.conf to modify kernel parameters and set the network card configuration to enable IPv6 according to the operating system type.
25+
26+
27+
#### Enable IPv4/IPv6 dual-stack on K8s cluster
28+
29+
Configure the CIDR of K8s components and network plugin. Normally, kube-apiserver and kube-controller-manager are maintained by static container in the control node, static container YAMLs are in the /etc/kubernetes/manifests directory. kube-proxy and network plugin are maintained by DaemonSet. Kubelet is maintained by Systemd in each node.
30+
31+
- kube-apiserver: Configure the command args
32+
- `--server-cluster-ip-range=<IPv4 CIDR>,<IPv6 CIDR>`
33+
- kube-controller-manager: Configure the command args
34+
- `--cluster-cidr=<IPv4 CIDR>,<IPv6 CIDR>`
35+
- `--service-cluster-ip-range=<IPv4 CIDR>,<IPv6 CIDR>`
36+
- `--node-cidr-mask-size-ipv4 | --node-cidr-mask-size-ipv6` defaults to /24 for IPv4 and /64 for IPv6
37+
- kube-proxy: Configure the ConfigMap and restart the DaemonSet
38+
- `kubectl -n kube-system edit configmaps kube-proxy`, edit the property `clusterCIDR: <IPv4 CIDR>,<IPv6 CIDR>`
39+
- Restart the kube-proxy (if it does not work, delete the Pod)
40+
```bash
41+
kubectl -n kube-system rollout restart daemonsets kube-proxy
42+
```
43+
- kubelet: Configure the command args
44+
- `--node-ip=<IPv4 IP>,<IPv6 IP>`
45+
- Network plugin Calico (other plugins can refer to relevant documents to modify the configuration)
46+
- Edit the ConfigMap of Calico
47+
```bash
48+
kubectl -n kube-system edit configmap calico-config
49+
```
50+
Edit the ipam property
51+
```json
52+
"ipam": {
53+
"type": "calico-ipam",
54+
"assign_ipv4": true,
55+
"assign_ipv6": true
56+
}
57+
```
58+
- Edit the DaemonSet environments of Calico
59+
```bash
60+
kubectl -n kube-system set env daemonset/calico-node IP6=autodetect
61+
kubectl -n kube-system set env daemonset/calico-node FELIX_IPV6SUPPORT="true"
62+
kubectl -n kube-system set env daemonset/calico-node CALICO_IPV6POOL_NAT_OUTGOING="true"
63+
kubectl -n kube-system set env daemonset/calico-node CALICO_IPV4POOL_CIDR="<IPv4 CIDR>"
64+
kubectl -n kube-system set env daemonset/calico-node CALICO_IPV6POOL_CIDR="<IPv6 CIDR>"
65+
kubectl -n kube-system set env daemonset/calico-node IP_AUTODETECTION_METHOD="interface=<Name>"
66+
kubectl -n kube-system set env daemonset/calico-node IP6_AUTODETECTION_METHOD="interface=<Name>"
67+
```
68+
69+
70+
#### Edit the Service of CloudCore
71+
72+
```bash
73+
kubectl -n kubeedge edit svc cloudcore
74+
```
75+
76+
Edit ipFamilies and ipFamilyPolicy properties in YAML.
77+
```yaml
78+
kind: Service
79+
apiVersion: v1
80+
metadata:
81+
name: cloudcore
82+
namespace: kubeedge
83+
...
84+
spec:
85+
...
86+
ipFamilies:
87+
- IPv4
88+
- IPv6
89+
ipFamilyPolicy: PreferDualStack
90+
```
91+
92+
Call the https service of CloudCore to verify whether the configuration is successful.
93+
```bash
94+
curl -gk6 "https://[<node_ipv6_address>]:<cloudhub-https-port>/ca.crt"
95+
```
96+
97+
#### Regenerate the KubeEdge certificate (Optional)
98+
99+
If K8s supports IPv6 before installing KubeEdge, skip this step.
100+
101+
Edit the ConfigMap of CloudCore.
102+
```bash
103+
kubectl -n kubeedge edit configmaps cloudcore
104+
```
105+
106+
Edit the advertiseAddress property to add IPv6 IP.
107+
```yaml
108+
modules:
109+
cloudHub:
110+
advertiseAddress:
111+
- <IPv4 IP>
112+
- <IPv6 IP>
113+
```
114+
115+
Delete the old secrets.
116+
```bash
117+
kubectl -n kubeedge delete secrets tokensecret casecret cloudcoresecret
118+
```
119+
120+
Restart CloudCore (if it does not work, delete the Pod).
121+
```bash
122+
kubectl -n kubeedge rollout restart deployments/cloudcore
123+
```
124+
125+
126+
### Join the edge node with IPv6
127+
128+
Directly use the IPv6 address to join the edge node, the IPv6 address needs to be defined in `[]`.
129+
```bash
130+
keadm join --cloudcore-ipport=[<IPv6 IP>]:<Port> --token=...
131+
```
132+
133+
Normally, the edge node will only report the IPv4 address to the cloud. If you need to report the IPv6 address, you can modify the configuration file /etc/kubeedge/config/edgecore.yaml and add the nodeIP under the edged property to specify the reported address.
134+
```yaml
135+
modules:
136+
edged:
137+
nodeIP: <Node IPv4 IP>,<Node IPv6 IP>
138+
```
139+
140+
After configuration, the node will report two IP addresses and show them in the status.
141+
```yaml
142+
status:
143+
addresses:
144+
- type: InternalIP
145+
address: <IPv4 IP>
146+
- type: InternalIP
147+
address: <IPv6 IP>
148+
```
149+
150+
Finally, use `kubectl get node` command on the cloud to check whether the edge node is ready.
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
---
2+
title: CloudHub-EdgeHub 支持 IPv6
3+
sidebar_position: 8
4+
---
5+
6+
## 概要
7+
8+
随着物联网设备的激增和对实时数据处理需求的不断增长,边缘计算逐渐成为一种重要的计算模式。边缘计算通过将数据处理和存储功能下沉到网络边缘,靠近数据源和用户,有效降低了延迟,提高了网络性能。然而,传统的IPv4协议在地址空间、路由效率和安全性等方面存在诸多局限,无法满足边缘计算日益增长的需求。IPv6作为下一代互联网协议,凭借其广阔的空间、高效的路由机制和强大的安全性,成为边缘计算的理想选择。
9+
10+
11+
## 操作方式
12+
13+
### 云端配置
14+
15+
当 EdgeCore 使用 K8s 原生服务能力访问 CloudCore(Ingress 或者 NodePort),则云端 K8s 集群网络需要开启 IPv4/IPv6 双协议栈。
16+
17+
:::note
18+
如果 CloudCore 用 hostNetwork 模式暴露服务,则 K8s 集群无需开启双协议栈网络,EdgeCore 只需要通过 CloudCore 所在节点的 IPv6 地址+端口即可访问 CloudCore。
19+
:::
20+
21+
22+
#### 确保节点支持 IPv6
23+
24+
首先需要确保节点是否开启 IPv6,使用命令查看 IPv6 路由:`ip -6 route show`。如果有输出说明已支持,否则需要配置 /etc/sysctl.conf 修改内核参数,并且按操作系统类型设置网卡配置开启 IPv6。
25+
26+
27+
#### 云端 K8s 集群开启双栈协议
28+
29+
配置 K8s 各个组件以及网络插件的 CIDR,正常情况 kube-apiserver 和 kube-controller-manager 在控制节点中使用静态容器维护,YAML 在 /etc/kubernetes/manifests 目录下。kube-proxy 和网络插件以 DaemonSet 方式维护。kubelet 则是在每个节点中以 Systemd 方式维护。
30+
- kube-apiserver 修改启动参数
31+
- `--server-cluster-ip-range=<IPv4 CIDR>,<IPv6 CIDR>`
32+
- kube-controller-manager 修改启动参数
33+
- `--cluster-cidr=<IPv4 CIDR>,<IPv6 CIDR>`
34+
- `--service-cluster-ip-range=<IPv4 CIDR>,<IPv6 CIDR>`
35+
- `--node-cidr-mask-size-ipv4 | --node-cidr-mask-size-ipv6` 对于 IPv4 默认为 /24,对于 IPv6 默认为 /64
36+
- kube-proxy 修改配置文件并重启 DaemonSet
37+
- 修改配置 `kubectl -n kube-system edit configmaps kube-proxy`,修改字段 `clusterCIDR: <IPv4 CIDR>,<IPv6 CIDR>`
38+
- 重启 kube-proxy (如果不行,删除 Pod)
39+
```bash
40+
kubectl -n kube-system rollout restart daemonsets kube-proxy
41+
```
42+
- kubelet 修改启动参数
43+
- `--node-ip=<IPv4 IP>,<IPv6 IP>`
44+
- 修改网络插件 Calico (其他插件可以查找相关资料修改配置)
45+
- 修改 Calico 的 ConfigMap 配置
46+
```bash
47+
kubectl -n kube-system edit configmap calico-config
48+
```
49+
修改 ipam 字段
50+
```json
51+
"ipam": {
52+
"type": "calico-ipam",
53+
"assign_ipv4": true,
54+
"assign_ipv6": true
55+
}
56+
```
57+
- 修改 Calico 的 DaemonSet 环境变量
58+
```bash
59+
kubectl -n kube-system set env daemonset/calico-node IP6=autodetect
60+
kubectl -n kube-system set env daemonset/calico-node FELIX_IPV6SUPPORT="true"
61+
kubectl -n kube-system set env daemonset/calico-node CALICO_IPV6POOL_NAT_OUTGOING="true"
62+
kubectl -n kube-system set env daemonset/calico-node CALICO_IPV4POOL_CIDR="<IPv4 CIDR>"
63+
kubectl -n kube-system set env daemonset/calico-node CALICO_IPV6POOL_CIDR="<IPv6 CIDR>"
64+
kubectl -n kube-system set env daemonset/calico-node IP_AUTODETECTION_METHOD="interface=<Name>"
65+
kubectl -n kube-system set env daemonset/calico-node IP6_AUTODETECTION_METHOD="interface=<Name>"
66+
```
67+
68+
69+
#### 修改 CloudCore 的 Service
70+
71+
```bash
72+
kubectl -n kubeedge edit svc cloudcore
73+
```
74+
75+
编辑 YAML 中的 ipFamilies 和 ipFamilyPolicy 字段
76+
```yaml
77+
kind: Service
78+
apiVersion: v1
79+
metadata:
80+
name: cloudcore
81+
namespace: kubeedge
82+
...
83+
spec:
84+
...
85+
ipFamilies:
86+
- IPv4
87+
- IPv6
88+
ipFamilyPolicy: PreferDualStack
89+
```
90+
91+
请求 CloudCore 的 https 服务验证配置是否成功
92+
```bash
93+
curl -gk6 "https://[<node_ipv6_address>]:<cloudhub-https-port>/ca.crt"
94+
```
95+
96+
#### 重新生成云端证书(可选)
97+
98+
K8s 先支持 IPv6 再安装 KubeEdge 的话无需操作。
99+
100+
修改 CloudCore 的 ConfigMap 配置
101+
```bash
102+
kubectl -n kubeedge edit configmaps cloudcore
103+
```
104+
105+
修改 advertiseAddress 添加 IPv6 的 IP 地址
106+
```yaml
107+
modules:
108+
cloudHub:
109+
advertiseAddress:
110+
- <IPv4 IP>
111+
- <IPv6 IP>
112+
```
113+
114+
删除老证书 secrets 资源
115+
```bash
116+
kubectl -n kubeedge delete secrets tokensecret casecret cloudcoresecret
117+
```
118+
119+
重启 CloudCore(如果不行,删除 Pod)
120+
```bash
121+
kubectl -n kubeedge rollout restart deployments/cloudcore
122+
```
123+
124+
125+
### 使用 IPv6 接入边缘节点
126+
127+
直接使用 IPv6 地址接入节点,注意 IPv6 地址需要定义在 `[]`
128+
```bash
129+
keadm join --cloudcore-ipport=[<IPv6 IP>]:<Port> --token=...
130+
```
131+
132+
正常情况下,节点只会上报 IPv4 的地址到云端,如果需要上报 IPv6 的地址,可以修改配置文件 /etc/kubeedge/config/edgecore.yaml,在 edged 下添加 nodeIP 字段指定上报的地址:
133+
```yaml
134+
modules:
135+
edged:
136+
nodeIP: <Node IPv4 IP>,<Node IPv6 IP>
137+
```
138+
139+
配置完后,节点会上报两个 IP 地址显示到节点状态中。
140+
```yaml
141+
status:
142+
addresses:
143+
- type: InternalIP
144+
address: <IPv4 IP>
145+
- type: InternalIP
146+
address: <IPv6 IP>
147+
```
148+
149+
最后在云端使用 `kubectl get node` 查看接入的节点是否 Ready。

0 commit comments

Comments
 (0)