Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

This article has participated in the “Digitalstar Project” and won a creative gift package to challenge the creative incentive money.

preface

The Internet of Things is already generating a staggering amount of data, which will grow exponentially with the deployment of 5G networks. Managing and using this data is a challenge.

Whether it’s generating information from traffic cameras, weather sensors, electricity meters, etc., combined with data from other cameras and sensors in a smart city environment, it can be too much to process in one central location, especially if you’re expecting devices to respond to events.

Kubernetes (K8s for short), which has been widely used in the ultra-large scale cloud computing environment, has been brought into the edge computing scene of the Internet of Things. The newly formed Kubernetes iot Edge Working Group will take the concept of running containers and extend it to the edge, facilitating the applicability of K8s in edge environments.

  • It supports the expansion of the number of connected devices of IIoT to millions, which can not only support IP devices to directly connect to K8s cloud platform, but also support non-IP devices to access through iot gateway.

  • Edge nodes are used to bring computing closer to devices to reduce latency, reduce bandwidth requirements, improve reliability, and meet users’ real-time, intelligent, data aggregation, and security requirements:

    • Deploying streaming data applications to edge nodes reduces bandwidth requirements for communication between devices and cloud platforms.

    • Deploying a serverless application framework allows the edge side to quickly respond to certain emergency situations without communicating with the cloud.

  • Provides a common control platform in hybrid cloud and edge environments to simplify administration and operation.

A background

1.1 KubeEdge profile

KubeEdge is an open source system that extends native containerized application orchestration and management to edge devices. Built on Kubernetes, it provides core infrastructure support for networks and applications, deploying applications in the cloud and on the edge, and synchronizing metadata. KubeEdge also supports the MQTT protocol, which allows developers to write client logic and enable resource constraints for device communication on the edge side. KubeEdge consists of two parts: cloud and edge.

1.2 KubeEdge characteristics

Edge of computing

By running the business logic at 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 times and protects customer data privacy.

Simplify the development

Developers can write regular HTTP – or MQTT-based applications that can be containerized and run anywhere on the edge or in the cloud.

Kubernetes native support

With KubeEdge, users can orchestrate applications, manage devices, and monitor application/device status on edge nodes, just as they would on a Kubernetes cluster in the cloud.

Rich applications

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

Two KubeEdge profile

2.1 KubeEdge architecture

2.2 Architecture details

2.2.1 Part above the cloud

  • CloudHub: CloudHub is a Web Socket server that listens for changes in the cloud, caches and sends messages to the EdgeHub.
  • EdgeController: The EdgeController is an extended Kubernetes controller that manages metadata for edge nodes and Pods to ensure that data is delivered 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 Edges

  • EdgeHub: EdgeHub is a Web Socket client that interacts with Edge computing cloud services (such as Edge Controller in KubeEdge architecture diagram), including synchronizing cloud resource updates and reporting Edge hosts and device status changes to the cloud.
  • Edged: Edged is an agent running on edge nodes to manage containerized applications.
  • EventBus: EventBus is a MOSQUITotMQTT client that interacts with the MQTT server (Mosquitto) to provide subscription and publishing capabilities to other components.
  • ServiceBus: The ServiceBus is an HTTP client running on the edge. It receives requests from cloud services and interacts with the HTTP server running on the edge, enabling cloud services to access the HTTP server on the edge over HTTP.
  • DeviceTwin: DeviceTwin is responsible for storing device status and synchronizing device status to the cloud. It also provides a query interface for applications.
  • MetaManager: The MetaManager is a message processor, which is located between the Edgeedge and Edgehub. It stores/retrieves metadata into a lightweight database (SQLite).

Iii Actual Combat Deployment

3.1 keadm deployment

Matters needing attention:

  • Currently supportedkeadmUbuntu and CentOS operating systems RaspberryPi support is ongoing.
  • You need superuser privileges (or root privileges) to run.

3.1.1 Setting up the cloud (KubeEdge main node)

By default, the edge node needs to have access to ports and ports in Cloudcore.

Keadm init will install Cloudcore, generate the certificate, and install CRD. It also provides a flag that allows you to set a specific version.

Important note: 1. At least one of kubeconFig or Master must be configured correctly so that it can be used to verify k8S cluster version and other information. 1. Ensure that the edge node can connect to the cloud node using the local IP address of the cloud node, or use the –advertise-address flag to specify the public IP address of the cloud node. 1. –advertise-address (available only after version 1.3) is the address exposed in the cloud (added to the SAN of the CloudCore certificate). The default value is the local IP address.

Example:

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

Output:

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

3.1.2 Setting edge End (KubeEdge working node)

  • Get the token from the cloud

Keadm GetToken running in the cloud returns a token that will be used when joining edge nodes.

# keadm gettoken27a37ef16159f7d3be8fae95d588b79b3adaaf92727b72659eb89758c66ffda2.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTAyMT YwNzd9.JBj8LLYWXwbbvHKffJBpPd5CyxqapRQYDIXtFZErgYECopy the code
  • Add edge node

Keadm Join will install edgecore and MQTT. It also provides a flag that allows you to set a specific version.

Example:

#Keadm join -- cloudcore - ipport = 192.168.20.50:10000 --token=27a37ef16159f7d3be8fae95d588b79b3adaaf92727b72659eb89758c66ffda2.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOj E1OTAyMTYwNzd9.JBj8LLYWXwbbvHKffJBpPd5CyxqapRQYDIXtFZErgYE
Copy the code
  • Important Note: 1. --cloudcore-ipportFlag is a mandatory flag. 1. If you want to automatically apply for certificates for edge nodes,--tokenYou need to. 1. Use the same version of kubeEdge on the cloud and edge.

Output:

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

3.2 Binary Deployment

Matters needing attention:

  • You need superuser privileges (or root privileges) to run.

3.2.1 Setting up the cloud (KubeEdge main node)

  • Create the 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.yamlCopy the code
  • Preparing configuration Files
# cloudcore --minconfig > cloudcore.yaml
Copy the code

For details, see Cloud Configuration.

  • run
# cloudcore --config cloudcore.yaml
Copy the code

3.2.2 Setting edge End (KubeEdge working node)

3.2.2.1 Preparing the Configuration File

  • Generating a Configuration File
# edgecore --minconfig > edgecore.yaml
Copy the code
  • Currency replaced in the cloud:
# kubectl get secret -nkubeedge tokensecret -o=jsonpath='{.data.tokendata}' | base64 -d
Copy the code
  • Update the token value in the Edgecore configuration file:
# sed -i -e "s|token: .*|token: ${token}|g" edgecore.yaml
Copy the code

This token is the result of the previous step.

For details, see Edge configuration.

3.2.2.2 run

To run Cloudcore and edgecore on the same host, run the following command:

# export CHECK_EDGECORE_ENVIRONMENT="false"
Copy the code

Activate marginal nucleus:

# edgecore --config edgecore.yaml
Copy the code

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

Four reflection

K8s is penetrating into edge computing, which provides convenience for edge-side application deployment, changes the relationship between edge application and hardware to some extent, and reduces the degree of coupling between the two. Through KubeEdge, the “edge scenario” can be expanded to 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.

Gartner estimates that by 2025, more than 75% of enterprise generated data can be created and processed outside of traditional data centers and the cloud, and the promise of choreography systems like Kubernetes has proven to be the best tool for this task.

The resources

  • Github.com/kubeedge/ku…
  • www.cncf.io/blog/2020/0…