What is WebAssembly?
WebAssembly a.k.a. wasm
is a binary instruction format and virtual machine that brings near-native performance to web browser applications, and allows developers to build high-speed web apps in the language of their choice.
WasmEdge runtime
WasmEdge is a lightweight, high-performance, and extensible WebAssembly runtime for cloud native, edge, and decentralized applications. It powers serverless apps, embedded functions, microservices, smart contracts, and IoT devices.
WasmEdge Runtime was accepted to CNCF on
April 28, 2021
and is at the Sandbox project maturity level.
I assume that the person who reads this repository knows the Kubernetes part well
To run wasm inside the kind cluster, we need to perform a change at the node side where this workload will be scheduled.
Kind node images yet don't support wasm workloads out of the box. I hope that this will be added soon to support an option for mixed workload types. Kind releases page is well documented and I advise you to check it out.
The game changer in this topic is runwasi from the containerd
What this does is let you to change behaviour of the low-level container runtime runc, to support new containerd shim which runs wasm workloads.
To support this we need to build custom node image with crun. There is couple changes that we need to perfrom in order to containerd starts work with WasmEdge workload. There is setup for the containerd here which will be used for our runtimeclass that we use. One important thing as we use crun here, is to use annotaiton, in our case that is here.
Now we have prepared continerd to use new shim in order to manages container lifecycle events for wasm workload.
You can use this simple Makefile
Usage:
make [ COMMAND ]
Commands:
all Build cluster and run the example workload
node-image Build the custom kind node image
cluster Create the cluster
crun-workload Build a wasm workload image and load it into kind
crun-test Deploy a test job with mixed workloads and print their logs
clean Delete the kind cluster
docker Clear all from machine
To goes over complete flow use
make all
Check Ivan's other great explanations for containers, below is just one of the great examples!