|
| 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. |
0 commit comments