Files
talks/0-web-assembly-containers/README.org

2.7 KiB

Running web assembly in containers

In our recent blog post on Web Assembly we highlighted the implementation of WASM support into the crun Open Container Initiative (OCI) runtime. This change paves the way for Podman and OpenShift to run WASM workloads.

This demo will step through how WASM modules can be run alongside traditional workloads in Podman.

Install wasm runtime

Our first pre-requisite step is to ensure our machine has a WASM runtime installed. For this demo we will use WasmEdge.

Run the code block below to install WasmEdge into the /usr/local/ dir using the project install script.

# Install via script
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | sudo bash -s -- -p /usr/local

# Verify installed version
wasmedge --version

Compile crun with wasm support

Once wasmedge is available we then need to ensure we have a version of crun available that has support for WASM. In my case I needed to download and compile a newer release including the --with-wasmedge compile flag.

We need to start with installing compile dependencies, these are listed here in the official docs.

sudo apt-get install --yes make git gcc build-essential pkgconf libtool libsystemd-dev libprotobuf-c-dev libcap-dev libseccomp-dev libyajl-dev libgcrypt20-dev go-md2man autoconf python3 automake

Once the required dependencies are present on our system we can clone down the source and compile it with the additional wasmedge flag.

# Clone the crun source
git clone https://github.com/containers/crun && cd crun

# Compile with wasm flag
./autogen.sh
./configure --with-wasmedge
make
sudo make install

# Cleanup the crun source
cd ../ and rm -rf crun

If everything worked correctly we can see the +WASM:wasmedge flag in our crun version information:

crun --version

The output should look something like the example below:

crun version 1.7.2.0.0.0.80-940b
commit: 940bf973f144c81149cf05135f127ca6f0d19eb6
rundir: /run/user/1000/crun
spec: 1.0.0
+SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +WASM:wasmedge +YAJL