In the previous blogs, i shared some personal viewpoints of edge computing and hopefully it will take off soon in the near future. As i promised, in this blog also the last piece of series of edge computing, i am going to create a demo to show how edge computing can be implemented in real life. As discussed, edge computing will utilize the container technology to be the foundation as infrastructure for applications. The common candidate of a container platform currently is Kubernetes therefore it will be used in this demo too. I will use K8S as a container platform for all the theories related to container technology in this blog.
In fact, edge computing can be deployed in the below implementation:
- A K8S cluster with multiple worker nodes running at edge locations. All the applications will be run on those edge locations to connect to edge devices.
- Each edge device will be a node in a K8S cluster. [2]
Another concept that is indispensable in edge use cases is Digital Twin. In a nutshell, digital twin is a concept of cloning edge devices to a centralized management platform. In this case, all the information of edge devices is reflected via digital twin. If there are any changes in states of edge devices, it will be transferred to management platform and vice versa. For more information of Digital Twin, it can be found here:
Time for the SHOW!!!!!
- Environment:
- I run 3 nodes to install K8S cluster using kubeadm, but i only use controller and edge2 nodes for this demo.
- All the nodes are running Ubuntu 20.04
- The amount of resources such as RAM, CPU, etc. are just enough for demo
- Technologies:
- K8S will be used for container management platform
- Kubeedge will be used for edge computing usecases. Kubeedge is a CNCF project donated by Huawei. More information can be found here: https://kubeedge.io/en/
- What to show?
- I am going to demo the second use case [2] as mentioned in the above.
- Edge2 will be used as a node in a K8S cluster as well as edge device. In this case, edge device is also a node in K8S.
- On edge2: There will be an app written in golang to simulate a traffic light.
- On controller: There will be an app written in golang using beego app framework to simulate the central control.
- There will be a frontend of app running on controller node to be easy to show the interactions.
- How do they communicate:
- On the frontend: It will be shown with traffic light. Each time user click on the picture representing light (green, yellow, red), signal will be transferred to edge device and edge device will response based on the color of signal (moving, slow moving or stop moving).
- A digital twin is created as a CRD in K8S to reflect the edge device which is traffic light.
DEMO TIME:
– Here is the snapshot of environment:
– As you can see, here is the snapshot of frontend:
– When i click on each light, the below is the responses of edge device:
– Click on GREEN, the response is: “Sending KEEP moving message” and “Keep moving” and continues printing message.
– Click on YELLOW, the response is: “Sending SLOW moving message to channel” and continues printing message
– Click on RED, the response is: “Sending STOP moving message to channel” and “Light is RED, stop moving” and stop printing message.
I also deployed an EdgeMesh for edge devices can be communicated each other as below:
It means that, dns of services running on edge device using EdgeMesh is now RESOLVED.
So, this demo is just for DEMO, not used for production. The purpose of this demo is showing how edge can be implemented in real life. The source code of this demo is uploaded here: https://github.com/vietstacker/kubeedge-trafficlight-app