Getting Started with OpenYurt on Raspberry Pi

By Tang Bingchang (Changpu)

With the rapid development of edge computing, more data needs to be stored, processed, and analyzed at the edge of the network. Devices and applications on the edge are growing rapidly. Managing the resources and applications efficiently on the edge has become a major challenge in the industry. Currently, the cloud-edge-end unification architecture has gained wide recognition in the industry. In this architecture, the cloud computing capability is delivered to the edge in a cloud-native way and is scheduled and managed on the cloud in a unified manner.

In May 2020, OpenYurt, Alibaba’s first cloud-native edge computing project with non-intrusive Kubernetes, was opened to developers. It entered the Cloud-Native Computing Foundation (CNCF) Sandbox in September of the same year. OpenYurt is an enhancement for native Kubernetes in a non-intrusive way to address issues, such as network instability and O&M difficulties in edge scenarios. It provides features, such as edge node autonomy, cloud-edge O&M channels, and edge unitization.

As shown in Figure 1, this article explains how to deploy a control plane of Kubernetes clusters on the cloud and connect Raspberry Pi to clusters to build cloud-channel-edge scenarios. Based on this, the core capabilities of OpenYurt will be demonstrated to help you get started with OpenYurt quickly.

Figure 1: Native Kubernetes cluster

Preparations

The control components of the native Kubernetes clusters can be deployed on the cloud by purchasing the Edge Node Service (ENS). ENS nodes are equipped with public IP addresses so services can be exposed through the public network. The system uses Ubuntu18.04 with master-node as the hostname. The version of Docker is 19.03.5.

As shown in Figure 2, on the edge, Raspberry Pi 4 is connected with the local router to form an edge private network environment. The router accesses the Internet through a 4G network card. The pre-installed system of the Raspberry Pi 4 is Ubuntu18.04 with edge-node as the hostname, and the version of Docker is 19.03.5.

Figure 2: Stereogram of the Edge Environment

The environment of this article is based on Kubernetes 1.16.6. Clusters are constructed through kubeadm provided by the community. The procedure is listed below:

  • Run the following commands on the cloud nodes and Raspberry Pi to install Kubernetes components
  • Use kubeadm to initialize the cloud nodes after running the following command. An Alibaba Cloud image warehouse is used during the deployment. To make sure Raspberry Pi is connected to the warehouse, a manifest list is created in the warehouse image to make sure Raspberry Pi is connected to the warehouse and to support AMD64 and ARM64 CPU architectures.

After the initialization is completed, copy the config file to the $HOME/.kube file.

  • Information should be accessed based on the nodes that are output after the second step of initialization to connect Raspberry Pi with cloud clusters. Then, run the following access command on Raspberry Pi
  • Add the Container Network Interface (CNI) configurations. The cloud control nodes and Raspberry Pi must be configured. The cluster construction mentioned in this article involves a host network. Create the CNI configuration file /etc/cni/net.d/0-loopback.conf and copy the following content to the file.
  • Check the deployment results on the master node
  • Delete CoreDNS. In this article, CoreDNS is not required. Remove the taints of the master node to facilitate the subsequent deployment of OpenYurt components.

The Problems of Native Kubernetes Clusters in Edge Scenarios

Based on the preceding environment, let’s test the native Kubernetes support for O&M on cloud-edge and its reaction to the disconnection of the cloud-edge network in the cloud-channel-edge architecture. First, deploy the test application NGINX on the cloud and run kubectl apply -f nginx.yaml on the master node. The specific deployment is listed below:

Note: Select edge-node for nodeSelector. Set host network to true, and set the pod tolerance time to 5 seconds. The default value is 5 minutes. The configuration here is for demonstrating pod evictions.

Check the deployment results

For the O&M of edge node applications on the master node, run logs, exec, port-forward, and other instructions to view the results

The results show that native Kubernetes cannot provide cloud O&M for edge applications in cloud-channel-edge scenarios because edge nodes are deployed in users’ private network environments. The edge nodes cannot be accessed directly from the cloud through the IP addresses of the edge nodes.

The edge nodes are connected to the cloud management through the public network. However, the network is often unstable, and the cloud is disconnected. There are two disconnection-related tests listed below:

  1. Disconnect the network for 1 minute > restore the network
  2. Disconnect the network for 1 minute > restart the edge nodes > restore the network

Observe the status changes of the nodes and pods during the two tests. In this article, the network disconnection works by disconnecting the public network of routers.

1) Disconnect the Network for 1 Minute > Restore the Network

After the network is disconnected, the node state changes to NotReady about 40 seconds later. A normal node reports a heartbeat every 10 seconds. If it does not report a heartbeat four times, the control component considers the node abnormal.

After waiting for 5 seconds, application pods are expelled, and the state is changed to Terminating. Generally, the pods are expelled 5 minutes after the normal nodes become NotReady. Here, the tolerance time of pods is set to 5 seconds to test the result.

Restore the network and observe the changes of the nodes and pods

After the network connection is restored, the node state becomes Ready, and the business pod is cleared because kubelet on the edge node obtains the Terminating status of the business pod. Then, it deletes the business pod and returns the result of the successful deletion operation. The cloud is also cleaned up accordingly. At this point, the business pod is evicted due to the instability of the cloud-edge network. However, during the network disconnection, the edge node can work normally.

Re-create the application NGINX for the following test:

2) Disconnect the Network for 1 Minute > Restart the Edge Nodes > Restore the Network

Next, we tested the impact of the edge node restart on the business because of the network disconnection. One minute after the network disconnection, the nodes and pods are in the same state as the preceding test results. The Node is in the NotReady state, and the Pod is in the Terminating state. Switch to the private network environment to log on to the Raspberry Pi and restart it. After the restarting, wait for about 1 minute to check the container list on the nodes before and after the restart.

The following shows the container list on the edge nodes before restarting. The cloud and edge are disconnected. Although the pod obtained on the cloud is in the Terminating state, the Terminating operation is not watched by the edge. Therefore, the applications on the edge are running normally.

The following shows the container list on nodes after restarting. After the network is restored, kubelet cannot obtain pod information from the cloud and does not re-create pods.

After comparing the states before and after restarting, you can see that all pods on the edge node cannot be restored after the network is disconnected and restarted. In this case, when the cloud-edge becomes disconnected, applications cannot work once nodes are restarted.

Restore the network and observe the changes of the nodes and pods. As shown in the preceding test results, after the network is recovered, the nodes become Ready, and the business pods are cleared.

Next, deploy NGINX again to test OpenYurt clusters support for cloud-edge O&M and its response to cloud-edge network disconnection

One-Click Conversion from Native Kubernetes Clusters to OpenYurt Clusters

After exploring the shortcomings of native Kubernetes in the cloud-edge unification architecture, it is time to check whether this architecture is supported in the OpenYurt clusters. Now, the cluster conversion tool yurtctl provided by the OpenYurt community converts the native Kubernetes clusters to the OpenYurt clusters. Run the command below on the master node. The command designates the component image and cloud node and installs the cloud-edge operation channel yurt-tunnel.

The conversion takes about 2 minutes. After the conversion is completed, check the status of the business pods. You can see the conversion has no impact on the business pods. The kubectl get pod -w command can also be used to observe the status of the business pods at a new terminal during the conversion process.

The distribution of the components after the conversion is shown in Figure 3. The orange parts are OpenYurt components, and the blue parts are native Kubernetes components. Accordingly, we observe the pods on the cloud and edge nodes.

Figure 3: Distribution of OpenYurt Cluster Components

There are two pods related to the yurt cloud nodes, yurt-controller-manager and yurt-tunnel-server.

The yurt-hub (static pod) and yurt-tunnel-agent pods are added to the edge node.

Test the Capabilities of the OpenYurt Clusters in Edge Scenarios

When testing port-forward, run curl 127.0.0.1:8888 on the master node to access the NGINX service.

The demonstration shows that OpenYurt can support common cloud-edge O&M instructions.

Similarly, we repeat the two tests of network disconnection in the native Kubernetes. Before the tests, enable the autonomy for the edge node. In the OpenYurt clusters, the autonomy of edge nodes is identified by an annotation.

1) Disconnect the Network for 1 Minute > Restore the Network

Similarly, disconnect the public network of router and check the states of nodes and pods. After about 40 seconds, the state of the node changes to NotReady. After about 1 minute, the state of the pods remains Running and pods are not evicted.

Restore the network and check the states of nodes and pods. The nodes change to Ready, and the pods remain Running. This shows that when the cloud-edge network is unstable, it has no impact on the business pods on the edge node.

2) Disconnect Network for 1 Minute > Restart Edge Nodes > Restore the Network

Next, we test the impact of the edge node restart on the business because of the network disconnection. One minute after the network disconnection, the nodes and pods are in the same states as the preceding test results. Nodes are in the NotReady state, and pods are in the Running state. Similarly, log on to Raspberry Pi to restart Raspberry Pi and view the container list on the nodes before and after the restart.

The edge node container list before restart is shown below:

The edge node containers list after restart is shown below:

After comparing the state before and after restarting, you can see that the pods on the nodes can be started normally after the network is disconnected and restarted. OpenYurt’s node autonomy capability can ensure stable business operation under the network disconnection.

Restore the network, and the nodes are in the Ready state. Then, observe the status of the business pod. After the network is recovered, the business pod remains in the running state with a restart record, which meets the expectation.

Finally, we use yurtctl to convert the OpenYurt clusters to native Kubernetes clusters. Similarly, you can see there is no impact on existing business during the conversion process.

As Alibaba’s first cloud-native and open-source edge computing project, OpenYurt has been tested for a long time within Alibaba Group based on the commercial product ACK@Edge. It has been used in CDN, IoT, Hema Fresh, ENS, Cainiao, and many other scenarios. For edge scenarios, the project adheres to the native Kubernetes features and provides capabilities, such as edge node autonomy and cloud-edge-end unification O&M channel in the form of Addon. Thanks to the efforts of community members, we have released some open-source management capabilities of edge unitization. More edge management capabilities will be released in the future. Your participation and contribution are welcomed.

Original Source:

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com