You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -3,25 +3,23 @@ title: Create WebAssembly System Interface(WASI) node pools in Azure Kubernetes
3
3
description: Learn how to create a WebAssembly System Interface(WASI) node pool in Azure Kubernetes Service (AKS) to run your WebAssembly(WASM) workload on Kubernetes.
4
4
services: container-service
5
5
ms.topic: article
6
-
ms.date: 10/12/2021
6
+
ms.date: 10/19/2022
7
7
---
8
8
9
9
# Create WebAssembly System Interface (WASI) node pools in Azure Kubernetes Service (AKS) to run your WebAssembly (WASM) workload (preview)
10
10
11
-
[WebAssembly (WASM)][wasm] is a binary format that is optimized for fast download and maximum execution speed in a WASM runtime. A WASM runtime is designed to run on a target architecture and execute WebAssemblies in a sandbox, isolated from the host computer, at near-native performance. By default, WebAssemblies can't access resources on the host outside of the sandbox unless it is explicitly allowed, and they can't communicate over sockets to access things environment variables or HTTP traffic. The [WebAssembly System Interface (WASI)][wasi] standard defines an API for WASM runtimes to provide access to WebAssemblies to the environment and resources outside the host using a capabilities model. [Krustlet][krustlet] is an open-source project that allows WASM modules to be run on Kubernetes. Krustlet creates a kubelet that runs on nodes with a WASM/WASI runtime. AKS allows you to create node pools that run WASM assemblies using nodes with WASM/WASI runtimes and Krustlets.
11
+
[WebAssembly (WASM)][wasm] is a binary format that is optimized for fast download and maximum execution speed in a WASM runtime. A WASM runtime is designed to run on a target architecture and execute WebAssemblies in a sandbox, isolated from the host computer, at near-native performance. By default, WebAssemblies can't access resources on the host outside of the sandbox unless it is explicitly allowed, and they can't communicate over sockets to access things environment variables or HTTP traffic. The [WebAssembly System Interface (WASI)][wasi] standard defines an API for WASM runtimes to provide access to WebAssemblies to the environment and resources outside the host using a capabilities model.
12
+
13
+
> [!IMPORTANT]
14
+
> WASI nodepools now use [containerd shims][wasm-containerd-shims] to run WASM workloads. Previously, AKS used [Krustlet][krustlet] to allow WASM modules to be run on Kubernetes. If you are still using Krustlet-based WASI nodepools, you can migrate to containerd shims by creating a new WASI nodepool and migrating your workloads to the new nodepool.
12
15
13
16
## Before you begin
14
17
15
18
WASM/WASI node pools are currently in preview.
16
19
17
20
[!INCLUDE [preview features callout](./includes/preview/preview-callout.md)]
18
21
19
-
This article uses [Helm 3][helm] to install the *nginx* chart on a supported version of Kubernetes. Make sure that you are using the latest release of Helm and have access to the *bitnami* Helm repository. The steps outlined in this article may not be compatible with previous versions of the Helm chart or Kubernetes.
20
-
21
-
You must also have the following resource installed:
22
-
23
-
* The latest version of the Azure CLI.
24
-
* The `aks-preview` extension version 0.5.34 or later
22
+
You must also have the latest version of the Azure CLI and `aks-preview` extension installed.
25
23
26
24
### Register the `WasmNodePoolPreview` preview feature
27
25
@@ -59,12 +57,11 @@ az extension update --name aks-preview
59
57
60
58
### Limitations
61
59
62
-
*You can't run WebAssemblies and containers in the same node pool.
63
-
*Only the WebAssembly(WASI) runtime is available, using the Wasmtime provider.
60
+
*Currently, there are only containerd shims available for [spin][spin]and [slight][slight] applications, which use the [wasmtime][wasmtime] runtime. In addition to wasmtime runtime applications, you can also run containers on WASI/WASM node pools.
61
+
*You can run containers and wasm modules on the same node, but you can't run containers and wasm modules on the same pod.
64
62
* The WASM/WASI node pools can't be used for system node pool.
65
63
* The *os-type* for WASM/WASI node pools must be Linux.
66
-
* Krustlet doesn't work with Azure CNI at this time. For more information, see the [CNI Support for Kruslet GitHub issue][krustlet-cni-support].
67
-
* Krustlet doesn't provide networking configuration for WebAssemblies. The WebAssembly manifest must provide the networking configuration, such as IP address.
64
+
* You can't use the Azure portal to create WASM/WASI node pools.
68
65
69
66
## Add a WASM/WASI node pool to an existing AKS Cluster
70
67
@@ -76,7 +73,7 @@ az aks nodepool add \
76
73
--cluster-name myAKSCluster \
77
74
--name mywasipool \
78
75
--node-count 1 \
79
-
--workload-runtime wasmwasi
76
+
--workload-runtime WasmWasi
80
77
```
81
78
82
79
> [!NOTE]
@@ -85,25 +82,16 @@ az aks nodepool add \
85
82
Verify the *workloadRuntime* value using `az aks nodepool show`. For example:
86
83
87
84
```azurecli-interactive
88
-
az aks nodepool show -g myResourceGroup --cluster-name myAKSCluster -n mywasipool
85
+
az aks nodepool show -g myResourceGroup --cluster-name myAKSCluster -n mywasipool --query workloadRuntime
89
86
```
90
87
91
88
The following example output shows the *mywasipool* has the *workloadRuntime* type of *WasmWasi*.
92
89
93
90
```output
94
-
{
95
-
...
96
-
"name": "mywasipool",
97
-
..
98
-
"workloadRuntime": "WasmWasi"
99
-
}
91
+
$ az aks nodepool show -g myResourceGroup --cluster-name myAKSCluster -n mywasipool --query workloadRuntime
92
+
"WasmWasi"
100
93
```
101
94
102
-
For a WASM/WASI node pool, verify the taint is set to `kubernetes.io/arch=wasm32-wagi:NoSchedule` and `kubernetes.io/arch=wasm32-wagi:NoExecute`, which will prevent container pods from being scheduled on this node pool. Also, you should see nodeLabels to be `kubernetes.io/arch: wasm32-wasi`, which prevents WASM pods from being scheduled on regular container(OCI) node pools.
103
-
104
-
> [!NOTE]
105
-
> The taints for a WASI node pool are not visible using `az aks nodepool list`. Use `kubectl` to verify the taints are set on the nodes in the WASI node pool.
106
-
107
95
Configure `kubectl` to connect to your Kubernetes cluster using the [az aks get-credentials][az-aks-get-credentials] command. The following command:
108
96
109
97
```azurecli
@@ -114,14 +102,12 @@ Use `kubectl get nodes` to display the nodes in your cluster.
114
102
115
103
```output
116
104
$ kubectl get nodes -o wide
117
-
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
Save the value of *WASINODE_IP* as it is used in later step.
123
-
124
-
Use `kubectl describe node` to show the labels and taints on a node in the WASI node pool. The following example shows the details of *aks-mywasipool-12456878-vmss000000*.
110
+
Use `kubectl describe node` to show the labels on a node in the WASI node pool. The following example shows the details of *aks-mywasipool-12456878-vmss000000*.
To run a workload on a WASM/WASI node pool, add a node selector and tolerations to your deployment. For example:
124
+
Add a `RuntimeClass` for running [spin][spin] and [slight][slight] applications. Create a file named *wasm-runtimeclass.yaml* with the following content:
143
125
144
126
```yml
145
-
...
146
-
spec:
127
+
apiVersion: node.k8s.io/v1
128
+
kind: RuntimeClass
129
+
metadata:
130
+
name: "wasmtime-slight-v1"
131
+
handler: "slight"
132
+
scheduling:
147
133
nodeSelector:
148
-
kubernetes.io/arch: "wasm32-wagi"
149
-
tolerations:
150
-
- key: "node.kubernetes.io/network-unavailable"
151
-
operator: "Exists"
152
-
effect: "NoSchedule"
153
-
- key: "kubernetes.io/arch"
154
-
operator: "Equal"
155
-
value: "wasm32-wagi"
156
-
effect: "NoExecute"
157
-
- key: "kubernetes.io/arch"
158
-
operator: "Equal"
159
-
value: "wasm32-wagi"
160
-
effect: "NoSchedule"
161
-
...
162
-
```
163
-
164
-
To run a sample deployment, create a `wasi-example.yaml` file using the following YAML definition:
Using [Helm][helm], add the *bitnami* repository and install the *nginx* chart with the `values.yaml` file you created in the previous step. Installing NGINX with the above `values.yaml` creates a reverse proxy to the example deployment, allowing you to access it using an external IP address.
191
+
> [!NOTE]
192
+
> When developing applications, modules should be build against the `wasm32-wasi` target. For more details, see the [spin][spin] and [slight][slight] documentation.
239
193
240
-
>[!NOTE]
241
-
> The following example pulls a public container image from Docker Hub. We recommend that you set up a pull secret to authenticate using a Docker Hub account instead of making an anonymous pull request. To improve reliability when working with public content, import and manage the image in a private Azure container registry. [Learn more about working with public images.][dockerhub-callout]
The follow example output confirms the example deployment is running.
209
+
Access the example application at `http://EXTERNAL-IP/hello`. The following example uses `curl`.
265
210
266
211
```output
267
-
$ curl EXTERNAL_IP/hello
268
-
hello world
212
+
$ curl http://EXTERNAL-IP/hello
213
+
hello
269
214
```
270
215
271
-
> [!NOTE]
272
-
> To publish the service on your own domain, see [Azure DNS][azure-dns-zone] and the [external-dns][external-dns] project.
216
+
> [!NOTE]
217
+
> If your request times out, use `kubectl get pods` and `kubectl describe pod <POD_NAME>` to check the status of the pod. If the pod is not running, use `kubectl get rs` and `kubectl describe rs <REPLICA_SET_NAME>` to see if the replica set is having issues creating a new pod.
273
218
274
219
## Clean up
275
220
276
-
To remove NGINX, use `helm delete`.
277
-
278
-
```console
279
-
helm delete hello-wasi
280
-
```
281
-
282
221
To remove the example deployment, use `kubectl delete`.
283
222
284
223
```azurecli-interactive
285
-
kubectl delete -f wasi-example.yaml
224
+
kubectl delete -f slight.yaml
286
225
```
287
226
288
227
To remove the WASM/WASI node pool, use `az aks nodepool delete`.
@@ -300,7 +239,10 @@ az aks nodepool delete --name mywasipool -g myresourcegroup --cluster-name myaks
0 commit comments