Skip to content

Commit ff3b53c

Browse files
committed
adjust docs for wasm functions
Signed-off-by: wrongerror <wangyifei@kubesphere.io>
1 parent 94e4f76 commit ff3b53c

File tree

2 files changed

+68
-22
lines changed

2 files changed

+68
-22
lines changed

content/en/docs/concepts/wasm_functions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ When `function.spec.workloadRuntime` is set to `wasmedge` or the function's anno
3333
> To setup `WasmEdge` workload runtime in kubernetes cluster and push images to a container registry,
3434
> please refer to the [prerequisites](../../getting-started/Quickstarts/prerequisites) section for more info.
3535
36+
> You can find more info about this sample Function [here](https://github.com/OpenFunction/samples/tree/main/functions/knative/wasmedge/http-server).
37+
3638
1. Create a wasm function
3739

3840
```shell

content/en/docs/getting-started/Quickstarts/prerequisites.md

Lines changed: 66 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -164,35 +164,79 @@ Function now supports using `WasmEdge` as workload runtime, here you can find st
164164
165165
> You should run the following steps on all the nodes (or a subset of the nodes that will host the wasm workload) of your cluster.
166166
167-
1. **WasmEdge**
167+
### Step 1 : Installing WasmEdge
168168
169169
The easiest way to install WasmEdge is to run the following command. Your system should have git and curl installed.
170170
```shell
171171
wget -qO- https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -p /usr/local
172172
```
173173
174-
2. **crun**
174+
### Step 2 : Installing Container runtimes
175175
176-
The crun project has WasmEdge support baked in. For now, the easiest approach is just download the binary and move it to `/usr/local/bin/`
177-
```shell
178-
wget https://github.com/OpenFunction/OpenFunction/releases/latest/download/crun-linux-amd64
179-
mv crun-linux-amd64 /usr/local/bin/crun
180-
```
181-
If the above approach does not work for you, please refer to [build and install a crun binary with WasmEdge support.](https://wasmedge.org/book/en/use_cases/kubernetes/container/crun.html)
176+
#### crun
182177
183-
3. **containerd**
178+
The crun project has WasmEdge support baked in. For now, the easiest approach is just download the binary and move it to `/usr/local/bin/`
179+
```shell
180+
wget https://github.com/OpenFunction/OpenFunction/releases/latest/download/crun-linux-amd64
181+
mv crun-linux-amd64 /usr/local/bin/crun
182+
```
183+
If the above approach does not work for you, please refer to [build and install a crun binary with WasmEdge support.](https://wasmedge.org/book/en/use_cases/kubernetes/container/crun.html)
184184
185-
Edit the configuration `/etc/containerd/config.toml`, add the following section to setup crun runtime, make sure the BinaryName equal to your crun binary path
186-
```
187-
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.crun]
188-
runtime_type = "io.containerd.runc.v2"
189-
pod_annotations = ["*.wasm.*", "wasm.*", "module.wasm.image/*", "*.module.wasm.image", "module.wasm.image/variant.*"]
190-
privileged_without_host_devices = false
191-
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.crun.options]
192-
BinaryName = "/usr/local/bin/crun"
193-
```
185+
### Step 3 : Setup CRI runtimes
194186
195-
Restart containerd service:
196-
```shell
197-
sudo systemctl restart containerd
198-
```
187+
#### Option 1: containerd
188+
189+
> You can follow this [installation guide](https://github.com/containerd/containerd/blob/main/docs/getting-started.md#installing-containerd) to install containerd and
190+
> this [setup guide](https://github.com/containerd/containerd/blob/main/docs/getting-started.md#setting-up-containerd-for-kubernetes) to setup containerd for Kubernetes.
191+
192+
First, edit the configuration `/etc/containerd/config.toml`, add the following section to setup crun runtime, make sure the BinaryName equal to your crun binary path
193+
```
194+
# Add crun runtime here
195+
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.crun]
196+
runtime_type = "io.containerd.runc.v2"
197+
pod_annotations = ["*.wasm.*", "wasm.*", "module.wasm.image/*", "*.module.wasm.image", "module.wasm.image/variant.*"]
198+
privileged_without_host_devices = false
199+
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.crun.options]
200+
BinaryName = "/usr/local/bin/crun"
201+
```
202+
203+
Next, restart containerd service:
204+
205+
```shell
206+
sudo systemctl restart containerd
207+
```
208+
209+
#### Option 2: CRI-O
210+
211+
> You can follow this [installation guide](https://github.com/cri-o/cri-o/blob/main/install.md) to install CRI-O and
212+
> this [setup guide](https://github.com/cri-o/cri-o/blob/main/tutorials/kubernetes.md#running-cri-o-on-kubernetes-cluster) to setup CRI-O for Kubernetes.
213+
214+
CRI-O uses the runc runtime by default and we need to configure it to use crun instead. That is done by adding to two configuration files.
215+
216+
First, create a `/etc/crio/crio.conf` file and add the following lines as its content. It tells CRI-O to use crun by default.
217+
218+
```
219+
[crio.runtime]
220+
default_runtime = "crun"
221+
```
222+
223+
The crun runtime is in turn defined in the `/etc/crio/crio.conf.d/01-crio-runc.conf` file.
224+
```
225+
[crio.runtime.runtimes.runc]
226+
runtime_path = "/usr/lib/cri-o-runc/sbin/runc"
227+
runtime_type = "oci"
228+
runtime_root = "/run/runc"
229+
# The above is the original content
230+
231+
# Add crun runtime here
232+
[crio.runtime.runtimes.crun]
233+
runtime_path = "/usr/local/bin/crun"
234+
runtime_type = "oci"
235+
runtime_root = "/run/crun"
236+
```
237+
238+
Next, restart CRI-O to apply the configuration changes.
239+
240+
```shell
241+
systemctl restart crio
242+
```

0 commit comments

Comments
 (0)