OpenYurt Out-of-the-Box Evaluation: Instantly Empower Native Kubernetes Clusters with Edge Computing Capabilities

Image for post
Image for post

By Zheng Chao, Senior Development Engineer at Alibaba Cloud

With the rapid development of Internet of Things (IoT) and 5G technologies, extending cloud computing capabilities to edge devices and ensuring unified delivery and management of edge devices through a centralized Kubernetes master have become important development trends in cloud computing. To help developers keep up with the trend, Alibaba officially released the cloud-native edge computing framework OpenYurt on May 29, 2020. The framework is based on the edge cluster hosting service (ACK@Edge).

OpenYurt has attracted the attention of developers since it was released. This article introduces OpenYurt and describes how you can use the OpenYurt command line tool Yurtctl to efficiently deploy OpenYurt clusters.

Introduction to OpenYurt

OpenYurt helps you perform large-scale application delivery, O&M, and control for massive volumes of edge and terminal resources. OpenYurt also provides channels for the provision of cloud computing services to edge applications. When the computing amount is large, cloud computing resources are used. When the computing amount is small, edge computing resources are used. OpenYurt is designed to conveniently extend native Kubernetes to the edge and provide a consistent user experience, without increasing the O&M workload.

Yurtctl: Instantly Empower Kubernetes Clusters with Edge Computing Capabilities

  • Edge autonomy (YurtHub: open source): When the cloud-edge network is unstable or disconnected or nodes are offline, applications running on the edge nodes are not affected.
  • Cloud-edge collaboration (to be made open source): OpenYurt uses cloud-edge O&M channels to meet edge O&M requirements and provides cloud-edge collaboration capabilities.
  • Unit-based management (to be made open source): OpenYurt provides unit-based closed-loop management for scattered edge nodes, edge applications, and the traffic between applications.
  • More capabilities to be added in the near future.

In addition, we must find a way to seamlessly integrate enhanced edge computing capabilities with native Kubernetes clusters. Based on the online O&M experience of ACK@Edge, we released the Yurtctl command line tool for seamless conversion between native Kubernetes and OpenYurt clusters and efficient O&M for OpenYurt components.

How Yurtctl Works

Image for post
Image for post
Figure 1: Yurtctl convert process

Yurtctl is a centralized management tool. In the OpenYurt cloud-edge architecture, Yurtctl interworks with API servers. It operates and maintains each node based on Job workloads in a native Kubernetes cluster. As shown in Figure 1, Yurtctl deploys a servant pod to the specified edge node through a Job workload during the convert operation.

For more information about the operations on containers in the servant pod, see: https://github.com/alibaba/openyurt/blob/master/config/yurtctl-servant/setup_edgenode

The servant pod needs to operate on the file system of the root user on the node (such as when storing the YurtHub configuration file in the /etc/kubernetes/manifests directory) and then reset the system management program kubelet.service. Therefore, containers in the servant pod are granted privileged permissions. They can share a PID namespace with the node and use the nsenter command to enter the primary namespace of the node to perform relevant operations. After the servant job workload is executed, it is deleted automatically. If the job workload fails to be executed, it is retained to help O&M personnel troubleshoot the cause of the error. With this mechanism, Yurtctl can also update or delete YurtHub.

Example: Instantly Converting a Kubernetes Cluster to an OpenYurt Cluster

Step 1. Obtain Yurtctl

$ make build WHAT=cmd/yurtctl
hack/make-rules/build.sh cmd/yurtctl
Building cmd/yurtctl

After successful compilation, you can find the Yurtctl executable file in the _output/bin/ directory.

Step 2. Convert a Kubernetes Cluster to an OpenYurt Cluster

$ yurtctl convert --cloud-nodes node1 --provider ack
I0603 14:34:33.714304 40825 convert.go:164] mark node1 as the cloud-node
I0603 14:34:33.719816 40825 convert.go:172] mark node2 as the edge-node
I0603 14:34:33.736609 40825 convert.go:198] deploy the yurt controller manager
I0603 14:34:33.742272 40825 convert.go:210] deploying the yurt-hub and resetting the kubelet service...
I0603 14:34:53.810165 40825 util.go:168] servant job(yurtctl-servant-convert-node2) has succeeded

After the nodes are configured, run the following command to mark the edge node as autonomous:

$yurtctl markautonomous# To mark only some edge nodes, use the autonomous-nodes option.
I0602 11:22:05.610222 89160 markautonomous.go:149] mark node2 as autonomous

Then, test whether node 2 is autonomous when the network is disconnected. Deploy a test pod on node 2.

$ kubectl apply -f-<<EOF
apiVersion: v1
kind: Pod
metadata:
name: bbox
spec:
nodeName: node2
containers:
- image: busybox
command:
- top
name: bbox
EOF
pod/bbox created

Log on to node 2 and set the server-addr parameter of YurtHub to an inaccessible address.

sudo sed -i 's|--server-addr=.*|--server-addr=https://1.1.1.1:1111|' /etc/kubernetes/manifests/yurt-hub.yaml

Wait for 40 seconds. The result shows that when node 2 is in the NotReady state, pod 1 is still in the Running state. This indicates that a pod deployed on an autonomous edge node will not be removed by the cloud node controller even when the autonomous edge node is offline.

$ kubectl get node 
NAME STATUS ROLES AGE VERSION
node1 Ready master 14m v1.14.8
node2 NotReady <none> 12m v1.14.8
$ kubectl get pod
NAME READY STATUS RESTARTS AGE
bbox 1/1 Running 0 5m12s

If node 2 is restarted, we can run the docker ps command to verify that the bbox pod will be restarted. It is assumed that node 2 uses Docker as the container runtime.

$ docker ps --format 'table {{.ID}}\t{{.Image}}\t{{.RunningFor}}' | grep busybox
d0c8134fddc1 busybox About a minutes ago

This is because the kubelet reads the cached data from YurtHub to restore the pod status before the restart. We will describe the technical details in subsequent articles.

Step 3. Converting an OpenYurt Cluster Back into a Kubernetes Cluster

$ yurtctl revert
I0603 14:38:55.522376 41016 revert.go:106] label alibabacloud.com/is-edge-worker is removed
I0603 14:38:55.527998 41016 revert.go:116] yurt controller manager is removed
I0603 14:38:55.548354 41016 revert.go:130] ServiceAccount node-controller is created
I0603 14:39:05.572686 41016 util.go:168] servant job(yurtctl-servant-revert-node2) has succeeded
I0603 14:39:05.572718 41016 revert.go:142] yurt-hub is removed, kubelet service is reset

For more information about how to use Yurtctl, see the following Yurtctl tutorial in the OpenYurt GitHub repository.
https://github.com/alibaba/openyurt/tree/master/docs/tutorial

What’s Next?

Community Construction

Original Source:

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

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