1
Abstract: K8s is penetrating edge computing. It provides convenience for edge application deployment, changes the relationship between edge applications and hardware to a certain extent, and reduces the coupling between the two.

This article is shared from the HUAWEI cloud community " Cloud Native Application in the Internet of Things [Please, the Internet of Things! ] ", author: kaliarch.

Preface

The Internet of Things has produced an astonishing amount of data, which will grow exponentially with the deployment of 5G networks. Managing and using this data is a challenge.

Whether it is information generated from traffic cameras, weather sensors, electricity meters, etc., this information is combined with data from other cameras and sensors in a smart city environment. It may be too much to process in a central location, especially when you are in the expected equipment When reacting to events.

Kubernetes (K8s for short), which has been commonly used in the super-large-scale cloud computing environment, is brought into the edge computing scenario of the Internet of Things. The newly established Kubernetes IoT Edge Working Group will adopt the concept of running containers and extend it to the edge to promote the application of K8s in the edge environment.

• Support the expansion of the number of connected devices of the Industrial Internet of Things to the million level, which can support IP devices directly connected to the K8s cloud platform, and support non-IP devices to access through the Internet of Things gateway.
• Use edge nodes to bring computing closer to the device side in order to reduce latency, reduce bandwidth requirements, and improve reliability to meet users' real-time, intelligence, data aggregation, and security needs:
o Deploy streaming data applications to edge nodes to reduce bandwidth requirements for communication between devices and cloud platforms.
o Deploy a serverless application framework so that the edge side can quickly respond to certain emergencies without communicating with the cloud.
• Provide a common control platform in hybrid cloud and edge environments to simplify management and operations.

A background

image.png

1.1 Introduction to KubeEdge

KubeEdge is an open source system that can extend native containerized application orchestration and management to edge devices. It is built on Kubernetes, provides core infrastructure support for networks and applications, deploys applications on the cloud and edge, and synchronizes metadata. KubeEdge also supports the MQTT protocol, allowing developers to write client logic and enable resource constraints for device communication at the edge. KubeEdge includes two parts: cloud and edge.

1.2 KubeEdge features

Edge computing

By running business logic on the edge, large amounts of data can be protected and processed locally. KubeEdge reduces bandwidth requests between the edge and the cloud, speeds up response time, and protects customer data privacy.

Simplify development

Developers can write regular http or mqtt-based applications, containerized and run anywhere on the edge or in the cloud.

Kubernetes native support

Using KubeEdge users can orchestrate applications, manage devices, and monitor application/device status on edge nodes, just like operating a Kubernetes cluster in the cloud.

Rich applications

Users can easily deploy complex machine learning, image recognition, event processing and other high-level applications to the edge.

Introduction to KubeEdge

2.1 KubeEdge architecture

image.png

2.2 Detailed structure

2.2.1 On the cloud

• CloudHub: CloudHub is a Web Socket server, responsible for monitoring changes in the cloud, caching and sending messages to EdgeHub.
• EdgeController: EdgeController is an extended Kubernetes controller that manages the metadata of edge nodes and Pods to ensure that data can be passed to the specified edge nodes.
• DeviceController: DeviceController is an extended Kubernetes controller that manages edge devices and ensures cloud-side synchronization of device information and device status.

2.2.2 Edge part

• EdgeHub: EdgeHub is a Web Socket client responsible for interacting with edge computing cloud services (such as the Edge Controller in the KubeEdge architecture diagram), including functions such as synchronizing cloud resource updates, reporting edge host and device status changes to the cloud.
• Edged: Edged is an agent running on edge nodes to manage containerized applications.
• EventBus: EventBus is an MQTT client that interacts with the MQTT server (mosquitto) and provides subscription and publishing functions for other components.
• ServiceBus: ServiceBus is an HTTP client running on the edge. It accepts requests from services on the cloud, interacts with the HTTP server running on the edge, and provides the ability for cloud services to access the edge HTTP server through the HTTP protocol.
• DeviceTwin: DeviceTwin is responsible for storing device status and synchronizing device status to the cloud. It also provides a query interface for applications.
• MetaManager: MetaManager is a message processor located between Edged and Edgehub. It is responsible for storing/retrieving metadata from a lightweight database (SQLite).

Three actual combat deployment

3.1 keadm deployment

Precautions:

• Currently supports keadmUbuntu and CentOS operating systems. RaspberryPi support is in progress.
• Requires super user privileges (or root privileges) to run.

3.1.1 Set up the cloud (KubeEdge master node)

By default, 10000 and 10002 edge nodes need to be able to access ports and ports in Cloudcore.

keadm init will install cloudcore, generate a certificate and install CRD. It also provides a flag that can be set to a specific version.

Important: 1. kubeconfig or master at least one must be properly configured for the version and other information k8s cluster for verification. 1. Please make sure that the edge node can use the local IP of the cloud node to connect to the cloud node, or you need to use the --advertise-address flag to specify the public IP of the cloud node. 1. --advertise-address (valid after version 1.3) is the address exposed by the cloud (it will be added to the SAN of the CloudCore certificate), and the default value is the local IP.

example:

# keadm init --advertise-address="THE-EXPOSED-IP"(only work since 1.3 release)

Output:

Kubernetes version verification passed, KubeEdge installation will start...
...
KubeEdge cloudcore is running, For logs visit:  /var/log/kubeedge/cloudcore.log

3.1.2 Setting the edge end (KubeEdge working node)

Obtain a token from the cloud
keadm gettoken running in the cloud will return a token, which will be used when joining edge nodes.

# keadm gettoken
27a37ef16159f7d3be8fae95d588b79b3adaaf92727b72659eb89758c66ffda2.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTAyMTYwNzd9.JBj8LLYWXwbbvHKffJBpPd5CyxqapRQYDIXtFZErgYE

Join edge node

Keadm join will install edgecore and mqtt. It also provides a flag that can be set to a specific version.

example:

# keadm join --cloudcore-ipport=192.168.20.50:10000 --token=27a37ef16159f7d3be8fae95d588b79b3adaaf92727b72659eb89758c66ffda2.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTAyMTYwNzd9.JBj8LLYWXwbbvHKffJBpPd5CyxqapRQYDIXtFZErgYE

Important: 1. --cloudcore-ipportflag mandatory sign. 1. If you want to automatically apply for a certificate for the edge node, --token is required. 1. The kubeEdge version used by the cloud and the edge must be the same.
Output:

Host has mosquit+ already installed and running. Hence skipping the installation steps !!!
...
KubeEdge edgecore is running, For logs visit:  /var/log/kubeedge/edgecore.log

3.2 Binary deployment

Precautions:

Requires super user privileges (or root privileges) to run.

3.2.1 Set up the cloud (KubeEdge master node)

Create CRD

kubectl apply -f https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/devices/devices_v1alpha2_device.yaml
kubectl apply -f https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/devices/devices_v1alpha2_devicemodel.yaml
kubectl apply -f https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/reliablesyncs/cluster_objectsync_v1alpha1.yaml
kubectl apply -f https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/reliablesyncs/objectsync_v1alpha1.yaml

Prepare configuration file
# cloudcore --minconfig > cloudcore.yaml
For details, please refer to Cloud Configuration.

run
# cloudcore --config cloudcore.yaml

3.2.2 Setting the edge end (KubeEdge working node)

3.2.2.1 Prepare configuration file

Generate configuration file
# edgecore --minconfig > edgecore.yaml
Get token value in the cloud:

# kubectl get secret -nkubeedge tokensecret -o=jsonpath='{.data.tokendata}' | base64 -d

Update the token value in the edgecore configuration file:

# sed -i -e "s|token: .*|token: ${token}|g" edgecore.yaml

This token is obtained from the above steps.

For details, please refer to the edge configuration.

3.2.2.2 Operation

If you want to run cloudcore and edgecore on the same host, first run the following command:

# export CHECK_EDGECORE_ENVIRONMENT="false"

Start edge core:

# edgecore --config edgecore.yaml
Run edgecore -h to get help information and add options as needed.

Four reflections

K8s is penetrating edge computing. It provides convenience for edge-side application deployment, changes the relationship between edge applications and hardware to a certain extent, and reduces the coupling between the two. Through KubeEdge, the expansion of "edge scenarios" can help users accelerate the realization of cloud-side collaboration, and complete the unified delivery, operation, maintenance, and control of large-scale applications on a large number of edge and end devices.

According to Gartner estimates, by 2025, more than 75% of enterprise-generated data can be created and processed outside of traditional data centers and clouds. Orchestration systems like Kubernetes have a bright future and have proven to be the best tool for this task. .

Reference

https://github.com/kubeedge/kubeedge/blob/master/README_zh.md
https://www.cncf.io/blog/2020/09/25/kubernetes-could-be-the-one-to-make-the-internet-of-things-iot-reach-its-potential/

Click to follow and learn about Huawei Cloud's fresh technology for the first time~


华为云开发者联盟
1.4k 声望1.8k 粉丝

生于云,长于云,让开发者成为决定性力量