- Install
wasmtime
curl https://wasmtime.dev/install.sh -sSf | bash
- Install rust with rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Install the
wasm32-wasi
target
rustup target add wasm32-wasi
- Run the example
cd hello-world
cargo build --target wasm32-wasi --release
wasmtime target/wasm32-wasi/release/hello-world.wasm
cd ..
- Install the
wasm32-wasi
target
rustup target add wasm32-wasi
- Build the example
cd tensorflow-mobilenet-v2
cargo build --target wasm32-wasi --release
- Run the example
wasmtime target/wasm32-wasi/release/example-tensorflow-mobilenet-v2.wasm --dir=.
- AOT Compilation
Let's now do an inference but this time with AOT compilation. Notice closely the time differences!
wasmtime compile target/wasm32-wasi/release/example-tensorflow-mobilenet-v2.wasm
wasmtime example-tensorflow-mobilenet-v2.cwasm --allow-precompiled --dir=.
cd ..
- Install
wabt
wget https://github.com/WebAssembly/wabt/releases/download/1.0.29/wabt-1.0.29-ubuntu.tar.gz
tar zxf wabt-1.0.29-ubuntu.tar.gz
- Convert Wasm to WAT
./wabt-1.0.29/bin/wasm2wat hello-world/target/wasm32-wasi/release/hello-world.wasm --output=hello-world.wat
- Register the
WasmNodePoolPreview
feature
az feature register --namespace "Microsoft.ContainerService" --name "WasmNodePoolPreview"
Running this command should show that the feature is registered:
az feature list -o table --query "[?contains(name, 'Microsoft.ContainerService/WasmNodePoolPreview')].{Name:name,State:properties.state}"
Refresh the registration of the ContainerService
resource:
az provider register --namespace Microsoft.ContainerService
- Install the
aks-preview
Azure CLI extension
az extension add --name aks-preview
- Create a new AKS cluster
az group create --name wasmRG -l westus
az aks create --resource-group wasmRG --name myAKScluster2
- Add a WASM/WASI node pool to an existing AKS Cluster
az aks nodepool add \
--resource-group wasmRG \
--cluster-name myAKScluster2 \
--name mywasipool \
--node-count 1 \
--workload-runtime wasmwasi
Verify the runtime:
az aks nodepool show -g reactor-demo --cluster-name myAKScluster2 -n mywasipool | jq '.workloadRuntime'
- Configure
kubectl
az aks get-credentials -n myAKScluster2 -g wasmRG
- Get the internal IP of the WASI node
kubectl get nodes -o wide
- Run a simple deployment
kubectl apply -f wasi-deployment/wasi-example.yaml
- Create a reverse proxy
Update the values.yaml
according to the internal IP of the load balancer which you can get with kubectl get svc
.
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
helm install hello-wasi bitnami/nginx -f wasi-deployment/values.yaml
kubectl get svc
- Try the deployment
curl EXTERNAL_IP/hello
- Install
wasm-to-oci
wget https://github.com/engineerd/wasm-to-oci/releases/download/v0.1.2/linux-amd64-wasm-to-oci
mv linux-amd64-wasm-to-oci wasm-to-oci
chmod +x wasm-to-oci
sudo cp wasm-to-oci /usr/local/bin
- Create a new container registry
az acr create -n reactordemo -g wasmRG --sku Standard
az acr login -n reactordemo
az acr update --name reactordemo --anonymous-pull-enabled
- Build the project:
cd aks-demo
cargo build --target wasm32-wasi --release
- Push the WASM image to the container registry
wasm-to-oci push target/wasm32-wasi/release/wasi_example_main.wasm reactordemo.azurecr.io/reactordemo:1.0.0
Verify the push:
az acr repository list -n reactordemo
az acr repository show -n reactordemo --image reactordemo:1.0.0
- Deploy the pod
kubectl apply -f pod.yaml
- Test the deployment
curl EXTERNAL_IP