author
SuperEdge Developer Team
summary
SuperEdge is an open source distributed edge computing container management system for , which is used to manage computing resources and container applications in multiple cloud edge regions. In the current architecture, these resources and applications can be managed as a Kubernetes-native resource.
In some cases, however, edge devices often require some lighter-weight, better-performing runtimes. It is also necessary to reduce container images in GB, and increase the startup time of containers to seconds or even milliseconds, and WebAssembly based on the virtual machine stack binary instruction format can better handle this situation.
WasmEdge is a lightweight, high-performance, and scalable WebAssembly runtime for cloud-native, edge, and decentralized applications. It is the fastest growing Wasm runtime today and has a very active community.
Running diagram
Superedge recently supported Containerd, and at the edge we will have Containerd use crun to support the WasmEdge runtime. That is, after following these steps, your edge nodes can support both OCI containers and WASM containers.
Install SuperEdge edge K8s cluster
- Download the installation package
arch=amd64 version=v0.7.0 && rm -rf edgeadm-linux-* && wget https://superedge-1253687700.cos.ap-guangzhou.myqcloud.com/$version/$arch/edgeadm-linux-containerd-$arch-$version.tgz && tar -xzvf edgeadm-linux-* && cd edgeadm-linux-$arch-$version && ./edgeadm
Pay attention to select the installation package corresponding to the machine architecture. This installation package has the Containerd container runtime by default.
- Create an edge cluster
./edgeadm init --kubernetes-version=1.18.2 --image-repository superedge.tencentcloudcr.com/superedge --service-cidr=10.96.0.0/12 --pod-network-cidr=192.168.0.0/16 --install-pkg-path ./kube-linux-*.tar.gz --apiserver-cert-extra-sans=<Master Public IP> --apiserver-advertise-address=<Master Intranet IP> --enable-edge=true --runtime=containerd
Note that with the parameter --runtime=containerd
, it means using the containerd container runtime, and --runtime=dockerd
means using the Docker container runtime.
- Join edge nodes
./edgeadm join <Master Public/Intranet IP Or Domain>:Port --token xxxx --discovery-token-ca-cert-hash sha256:xxxxxxxxxx --install-pkg-path ./kube-linux-*.tar.gz --enable-edge=true --runtime=containerd
For details, see SuperEdge official document One-click installation of native k8s cluster and edge K8s cluster
Install the WasmEdge runtime environment
Install WasmEdge
WasmEdge can be easily installed using a script on the edge node. Execute the following script on the edge node:
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash
install crunch
crun The project has built-in WasmEdge support, but the default crun release does not compile the wasmedge module. Currently, it is necessary to manually build the crun binary that supports WasmEdge from the source code.
First, make sure the crun dependencies are installed on your Ubuntu 20.04. For other Linux distributions see crun's README .
sudo apt update
sudo apt install -y make git gcc build-essential pkgconf libtool \
libsystemd-dev libprotobuf-c-dev libcap-dev libseccomp-dev libyajl-dev \
go-md2man libtool autoconf python3 automake
Next, compile and install crun:
git clone https://github.com/containers/crun
cd crun
./autogen.sh
./configure --with-wasmedge
make
sudo make install
Configure Containerd to use the crun runtime
Here we give the difference between the original configuration and the configuration of the containerd file /etc/containerd/config.toml
that needs to be configured. Users can modify it according to the comparison.
cat > config.toml.diff << EOF
--- /etc/containerd/config.toml 2022-02-14 15:05:40.061562127 +0800
+++ /etc/containerd/config.toml.crun 2022-02-14 15:03:35.846052853 +0800
@@ -24,17 +24,23 @@
max_concurrent_downloads = 10
[plugins.cri.containerd]
- default_runtime_name = "runc"
- [plugins.cri.containerd.runtimes.runc]
+ default_runtime_name = "crun"
+ [plugins.cri.containerd.runtimes.crun]
runtime_type = "io.containerd.runc.v2"
- pod_annotations = []
+ pod_annotations = ["*.wasm.*", "wasm.*", "module.wasm.image/*", "*.module.wasm.image", "module.wasm.image/variant.*"]
container_annotations = []
privileged_without_host_devices = false
- [plugins.cri.containerd.runtimes.runc.options]
- BinaryName = "runc"
+ [plugins.cri.containerd.runtimes.crun.options]
+ BinaryName = "crun"
# cni
[plugins.cri.cni]
bin_dir = "/opt/cni/bin"
conf_dir = "/etc/cni/net.d"
conf_template = ""
+ [plugins."io.containerd.runtime.v1.linux"]
+ no_shim = false
+ runtime = "crun"
+ runtime_root = ""
+ shim = "containerd-shim"
+ shim_debug = false
EOF
Finally restart the containerd container runtime
sudo patch -d/ -p0 < config.toml.diff
sudo systemctl restart containerd
Create a WASM application
We will use a wasm example image wasm-wasi-example 1623853b18bd88 already on . Here, the wasm image needs to add an Annotation of "module.wasm.image/variant":"compat"
to the image's Manfest file so that the runtime can distinguish between the wasm and the operating system, so the docker build function cannot be satisfied, you can use buildah to build the wasm image and push it to any OCI standard mirror repository.
cat > wasmedge-app.yaml << EOF
apiVersion: v1
kind: Pod
metadata:
annotations:
module.wasm.image/variant: compat
labels:
run: wasi-demo
name: wasi-demo
spec:
containers:
- args:
- /wasi_example_main.wasm
- "50000000"
image: hydai/wasm-wasi-example:with-wasm-annotation
imagePullPolicy: IfNotPresent
name: wasi-demo
hostNetwork: true
restartPolicy: Never
EOF
kubectl create -f wasmedge-app.yaml
Use kubectl logs wasi-demo
to see the output of this program as follows:
Random number: -1643170076
Random bytes: [15, 223, ... 106, 51]
Printed from wasi: This is from a main function
This is from a main function
The env vars are as follows.
The args are as follows.
/wasi_example_main.wasm
50000000
File content is This is in a file
future
With more extensive edge device access and more edge scenario coverage requirements, SuperEdge not only supports traditional docker and containerd in edge computing runtime, but also supports various WebAssembly runtimes (WasmEdge), and will continue to Create an imaginative and infinitely possible edge computing and scheduling platform for developers.
about Us
For more cases and knowledge about cloud native, you can pay attention to the public account of the same name [Tencent Cloud Native]~
Welfare:
① Reply to the [Manual] in the background of the official account, you can get the "Tencent Cloud Native Roadmap Manual" & "Tencent Cloud Native Best Practices"~
②The official account will reply to [series] in the background, and you can get "15 series of 100+ super practical cloud native original dry goods collection", including Kubernetes cost reduction and efficiency enhancement, K8s performance optimization practices, best practices and other series.
③If you reply to the [White Paper] in the background of the official account, you can get the "Tencent Cloud Container Security White Paper" & "The Source of Cost Reduction - Cloud Native Cost Management White Paper v1.0"
④ Reply to [Introduction to the Speed of Light] in the background of the official account, you can get a 50,000-word essence tutorial of Tencent Cloud experts, Prometheus and Grafana of the speed of light.
⑤ If you reply to the [Selected Collection] in the background of the official account, you can get a wonderful speech from 24 Tencent Cloud experts from Tencent - the 40,000-word "Tencent Cloud Technology Practice Collection 2021".
[Tencent Cloud Native] New products of Yunshuo, new techniques of Yunyan, new activities of Yunyou, and information of cloud appreciation, scan the code to follow the public account of the same name, and get more dry goods in time! !
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。