Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Podman with WebAssembly

うたもく
November 16, 2023

Podman with WebAssembly

うたもく

November 16, 2023
Tweet

More Decks by うたもく

Other Decks in Technology

Transcript

  1. 2 Preferred Networks, Inc. 社内向けオンプレML基盤の開発‧運⽤ OSS Activities as My Hobby

    Maintainer opencontainers/runtime-spec containers/youki Reviwer containerd/runwasi CNCF Ambassador Fall 2023 @utam0k Toru Komatsu
  2. 3 Preferred Networks, Inc. 社内向けオンプレML基盤の開発‧運⽤ OSS Activities as My Hobby

    Maintainer opencontainers/runtime-spec containers/youki Reviwer containerd/runwasi CNCF Ambassador Fall 2023 @utam0k Toru Komatsu
  3. Preparing for hello world in WebAssembly
 $ cargo new hello

    && cd hello $ cargo build --target wasm32-wasi $ cp target/wasm32-wasi/debug/hello.wasm .
  4. Preparing for a hello world in WebAssembly
 $ cargo new

    hello && cd hello $ cargo build --target wasm32-wasi $ cp target/wasm32-wasi/debug/hello.wasm . $ file hello.wasm hello.wasm: WebAssembly (wasm) binary module version 0x1 (MVP) $ ./hello.wasm zsh: exec format error: ./hello.wasm $ wasmedge hello.wasm Hello, world!
  5. Preparing Dockerfile
 $ cargo new hello && cd hello $

    cargo build --target wasm32-wasi $ cp target/wasm32-wasi/debug/hello.wasm . $ file hello.wasm hello.wasm: WebAssembly (wasm) binary module version 0x1 (MVP) $ ./hello.wasm zsh: exec format error: ./hello.wasm $ wasmedge hello.wasm Hello, world! $ cat Dockerfile FROM scratch COPY hello.wasm / ENTRYPOINT ["/hello.wasm"]
  6. Building container images for Wasm
 $ buildah build --annotation "module.wasm.image/variant=compat"

    -t hello-wasm . STEP 1/3: FROM scratch … snip … Successfully tagged localhost/hello-wasm:latest ca9fbef8860afe406c2ca37841f05c0def1ad23dde427fd06b2d5dda979cb58f
  7. Run
 $ buildah build --annotation "module.wasm.image/variant=compat" -t hello-wasm . STEP

    1/3: FROM scratch … snip … Successfully tagged localhost/hello-wasm:latest ca9fbef8860afe406c2ca37841f05c0def1ad23dde427fd06b2d5dda979cb58f $ podman run -it localhost/hello-wasm:latest Hello, world!
  8. Check if Podman Supports Wasm Execution
 $ podman info |

    grep -A 9 ociRuntime ociRuntime: name: crun package: 'crun: /usr/bin/crun' path: /usr/bin/crun version: |- crun version 1.11.2.0.0.0.9-e079 commit: e079a879a3f37b33d2a0f33289adc8902c144fb8 rundir: /run/crun spec: 1.0.0 +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +WASM:wasmedge +YAJL $ # If your environment doesn’t meet, please refer to https://wasmedge.org/docs/develop/deploy/oci-runtime/crun/#prerequisites
  9. Spoiler - ネタバレ -
 $ cat Dockerfile FROM docker.io/wasmedge/slim:0.13.5 COPY

    hello.wasm / ENTRYPOINT ["wasmedge", "/hello.wasm"] $ buildah build -t hello-wasmedge . STEP 1/3: FROM docker.io/wasmedge/slim:0.13.5 … snip … Successfully tagged localhost/hello-wasmedge:latest f1afe57d5771f82467ea4f23857dc6622faecba8d54fec335e97a06974c9be6e $ podman run -it --rm localhost/hello-wasmedge:latest Hello, world!
  10. WasmEdge Actively Begins Engagement in Low-Level Runtime Development crun second-state/crunw#6

    Nov 8, 2021 containers/cun#774#6 Nov 8, 2021 youki WasmEdge/WasmEdge#664 Nov 19, 2021 containers/youki#548e#664 Dec 20, 2021 runwasi Jan 23, 2022 ~
  11. Announcement of the Collaboration between runwasi and youki at KubeDay

    Japan, Dec 7, 2022 WebAssembly on Kubernetes runwasi Successfully Integrates with youki Apr 22, 2023 containerd/runwasi#78 Annoucement Docker + WebAssembly Oct 24, 2022 ← Now!
  12. $ cat Dockerfile FROM scratch COPY hello.wasm / ENTRYPOINT ["/hello.wasm"]

    $ buildah build --annotation "module.wasm.image/variant=compat" -t hello-wasm . STEP 1/3: FROM scratch … snip … Successfully tagged localhost/hello-wasm:latest ca9fbef8860afe406c2ca37841f05c0def1ad23dde427fd06b2d5dda979cb58f $ podman run -it localhost/hello-wasm:latest Hello, world!
  13. $ cat Dockerfile FROM scratch COPY hello.wasm / ENTRYPOINT ["/hello.wasm"]

    $ buildah build --annotation "module.wasm.image/variant=compat" -t hello-wasm . STEP 1/3: FROM scratch … snip … Successfully tagged localhost/hello-wasm:latest ca9fbef8860afe406c2ca37841f05c0def1ad23dde427fd06b2d5dda979cb58f $ podman run -it localhost/hello-wasm:latest Hello, world! $ cat Dockerfile FROM docker.io/wasmedge/slim:0.13.5 COPY hello.wasm / ENTRYPOINT ["wasmedge", "/hello.wasm"] $ sudo podman run -it --rm localhost/hello-wasmedge:latest Hello, world!
  14. Cutting-Edge of WebAssembly Containers
 Mixing Containers and Wasm Containers within

    a Kubernetes Pod • containerd/runwasi#64 • For Example, Sidecars Facilitating Easy Handling of Wasm with Images (OCI Artifacts) Support for Arbitrary Entry Point in WebAssembly • containerd/runwasi#102 [WIP] Definition and Support of Media Types for Wasm • containerd/containerd#8699 • bytecodealliance/registry#87