Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasmedge #192

Merged
merged 24 commits into from
Oct 31, 2023
Merged

Wasmedge #192

merged 24 commits into from
Oct 31, 2023

Conversation

vasilvas99
Copy link
Contributor

@vasilvas99 vasilvas99 commented Sep 12, 2023

WASM-based containers in Leda

General

WASM+WASI allows to develop for an abstract machine (WASM) with an abstract system interface (WASI ~ POSIX), compile once and deploy on any architecture/machine that has the appropriate WASM/WASI runtime.

WASMEdge is one such runtime that is lightweight, while supporting wasi-preview1 + some of the extensions provided by wasi-preview2 (e.g. sockets, threads).

Preview2-features are not stable yet (and officially supported by the compiler vendors such as clang, rustc, etc) so they require a lot of library patching/ad hoc solutions.

Therefore, developers are encouraged to limit themselves to WASI-preview1.

Implementation

  • LLVM 14 recipes backported from newer poky versions due to meta-clang requirements
  • meta-leda now depends on clang-layer
  • WASMedge-runtime + wasmedge .so libraries (allows developers to embed wasmedege in their applications) recipe implemented
  • crun recipe from openembedded patched to compile with the wasmedge feature (allows developers to run wasm-binaries in OCI containers
  • containerd reconfigured to use crun for the io.containerd.runc.v2 API
  • meta-clang added to kas-files
  • Kanto Container Management configured to work with WASM/WASI containers (see issues section)

Requirements

You now should include meta-clang, since wasm runtimes/compilers generally emit LLVM IR, which is then compiled by the system-specific LLVM to native code. If you use kas, add:

  meta-clang:
    url: https://github.com/kraj/meta-clang
    refspec: kirkstone

ref: https://github.com/eclipse-leda/leda-distro/compare/main...SoftwareDefinedVehicle:leda-distro-fork:wasmedge?expand=1

Test setup

This PR was tested by building from the wasmedge branch of https://github.com/SoftwareDefinedVehicle/leda-distro-fork

Tests

Builds created with this PR should be able to run the container examples from the wasmedge website:

https://wasmedge.org/docs/develop/deploy/cri-runtime/containerd-crun/

The quick-test example you can use to verify everything is correct is to run the "rng generator container" with.

sudo ctr i pull docker.io/wasmedge/example-wasi:latest

sudo ctr run --rm --runc-binary crun --runtime io.containerd.runc.v2 --label module.wasm.image/variant=compat-smart docker.io/wasmedge/example-wasi:latest wasm-example /wasi_example_main.wasm 50000000

Issues

CRUN depends on the top-level runtime providing the module.wasm.image/variant=compat-smart "magic" label for the container to distinguish WASM from "normal"/native containers. This is implemented as annotations in k8s.

Kanto Container Management however, does not seem to implement the labels part of the OCI spec (see The containers.proto file for containerd which requires the labels map to be handled specially by the top-level run-time). My assumption is that since "all" labels should be included in update calls and Kanto does not implement labels as part of its interface, they are never passed to containerd even if they were added in the dockerfile/manually with ctr after the image was pulled.

This limits the applicability of WASM containers in our case.

@vasilvas99 vasilvas99 requested a review from stlachev October 30, 2023 08:43
@vasilvas99 vasilvas99 marked this pull request as ready for review October 30, 2023 08:44
Copy link
Contributor

@stlachev stlachev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@stlachev stlachev merged commit 11c096c into eclipse-leda:main Oct 31, 2023
4 of 5 checks passed
@stlachev stlachev deleted the wasmedge branch October 31, 2023 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants