Giter VIP home page Giter VIP logo

kind-crun-wasm's Introduction

This repository is deprecated in favor of KWasm.sh

kind-crun-wasm

This repository shows how to run WASM on KinD. It is build on the awesome work of https://github.com/second-state/wasmedge-containers-examples.

Quickstart

To get started just run:

# Create a "WASM in KinD" Cluster
kind create cluster --image ghcr.io/liquid-reply/kind-crun-wasm:v1.23.4

To test the WASM capabilities of your cluster you can start the example:

# Run the example
kubectl run -it --rm --restart=Never wasi-demo --image=hydai/wasm-wasi-example:with-wasm-annotation --annotations="module.wasm.image/variant=compat" /wasi_example_main.wasm 50000000

To create your own containers you can start here: https://wasmedge.org/book/en/kubernetes/demo.html

Approach

Upstream Kind uses Containerd and runc to run Containers. However crun has built in support to run wasm workloads. Therefore this Repository patches the original Kind node image and replaces runc with crun.

KinD -> Containerd -> crun -> WasmEdge

How to run

To create a KinD cluster with WASMEdge support you can use the following cluster description:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  image: ghcr.io/liquid-reply/kind-crun-wasm:v1.23.4
- role: worker
  image: ghcr.io/liquid-reply/kind-crun-wasm:v1.23.4

Start the cluster:

kind create cluster --config=cluster.yaml

    Creating cluster "kind" ...
    โœ“ Ensuring node image (ghcr.io/liquid-reply/kind-crun-wasm:v1.23.4) ๐Ÿ–ผ 
    โœ“ Preparing nodes ๐Ÿ“ฆ ๐Ÿ“ฆ  
    โœ“ Writing configuration ๐Ÿ“œ 
    โœ“ Starting control-plane ๐Ÿ•น๏ธ 
    โœ“ Installing CNI ๐Ÿ”Œ 
    โœ“ Installing StorageClass ๐Ÿ’พ 
    โœ“ Joining worker nodes ๐Ÿšœ 
    Set kubectl context to "kind-kind"

Run the demo app:

kubectl run -it --rm --restart=Never wasi-demo --image=hydai/wasm-wasi-example:with-wasm-annotation --annotations="module.wasm.image/variant=compat" /wasi_example_main.wasm 50000000

    Random number: 1272007318
    Random bytes: [203, 141, 55, 34, 190, 15, 21, 226, 138, 11, 221, 207, 99, 95, 191, 61, 94, 51, 78, 227, 204, 87, 13, 159, 165, 105, 237, 171, 218, 51, 87, 123, 251, 211, 41, 252, 232, 239, 208, 229, 73, 237, 65, 217, 90, 8, 86, 80, 131, 134, 200, 89, 192, 60, 231, 166, 180, 1, 59, 11, 160, 5, 43, 199, 5, 165, 201, 6, 210, 167, 147, 135, 174, 136, 176, 211, 193, 186, 227, 208, 144, 141, 243, 5, 87, 77, 246, 227, 246, 60, 183, 100, 23, 194, 85, 139, 164, 153, 164, 151, 73, 53, 130, 82, 255, 109, 222, 182, 82, 177, 238, 13, 241, 9, 146, 184, 196, 57, 164, 121, 31, 162, 255, 211, 181, 61, 135, 154]
    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
    pod "wasi-demo" deleted

kind-crun-wasm's People

Contributors

0xe282b0 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.