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
Copy file name to clipboardexpand all lines: docs/develop/deploy/kubernetes/kubernetes-containerd-runwasi.md
+141-4
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,144 @@ sidebar_position: 3
4
4
5
5
# Kubernetes + Containerd + Runwasi
6
6
7
-
<!-- prettier-ignore -->
8
-
:::info
9
-
Work in Progress
10
-
:::
7
+
## Quick start
8
+
9
+
The [GitHub repo](https://github.com/second-state/wasmedge-containers-examples/) contains scripts and GitHub Actions for running our example apps on Kubernetes + containerd + runwasi.
10
+
11
+
- Simple WebAssembly example [Quick start](https://github.com/second-state/wasmedge-containers-examples/blob/main/kubernetes_containerd/README.md) | [Github Actions](https://github.com/second-state/wasmedge-containers-examples/blob/main/.github/workflows/kubernetes-containerd.yml)
12
+
- WebAssembly-based HTTP service [Quick start](https://github.com/second-state/wasmedge-containers-examples/blob/main/kubernetes_containerd/http_server/README.md) | [Github Actions](https://github.com/second-state/wasmedge-containers-examples/blob/main/.github/workflows/kubernetes-containerd-server.yml)
13
+
14
+
In the rest of this section, we will explain the steps in detail.
15
+
16
+
## Prerequisites for this setup
17
+
18
+
Please ensure that you have completed the following steps before proceeding with this setup.
19
+
20
+
- Install the latest version of [Wasmedge](../../../start/install.md)
21
+
- Ensure that you have containerd setup following the [instructions here](../../deploy/cri-runtime/containerd-crun.md).
22
+
- Ensure that you have installed and [setup runwasi](../../deploy/cri-runtime/containerd.md) for containerd-shim-wasmedge
23
+
24
+
25
+
26
+
## Install and start Kubernetes
27
+
28
+
Run the following commands from a terminal window. It sets up Kubernetes for local development.
Local Kubernetes cluster is running. Press Ctrl-C to shut it down.
55
+
```
56
+
57
+
Do NOT close your terminal window. Kubernetes is running!
58
+
59
+
60
+
## Run and test the Kubernetes Cluster
61
+
62
+
Finally, we can run WebAssembly programs in Kubernetes as containers in pods. In this section, we will start from **another terminal window** and start using the cluster.
63
+
64
+
```bash
65
+
export KUBERNETES_PROVIDER=local
66
+
67
+
sudo cluster/kubectl.sh config set-cluster local --server=https://localhost:6443 --certificate-authority=/var/run/kubernetes/server-ca.crt
echo'[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.wasmedge] runtime_type = "io.containerd.wasmedge.v1"'| sudo tee -a /etc/containerd/config.toml > /dev/null
98
+
sudo systemctl restart containerd
99
+
```
100
+
101
+
Next we will create a RuntimeClass in Kubernetes to specify usage of wasmedge runtime for objects labeled as `runtime=wasm`
Now we will label the kubernetes node as `runtime=wasm`. Note that the node where we changed the containerd configurations will be the one which we will label.
108
+
109
+
An example of how we can label the node is given below:
# A successful output from the above command looks like this
119
+
node/127.0.0.1 labeled
120
+
```
121
+
### A WebAssembly-based HTTP service
122
+
123
+
[A separate article](https://github.com/second-state/wasmedge-containers-examples/blob/main/http_server_wasi_app.md) explains how to compile, package, and publish a simple WebAssembly HTTP service application as a container image to Docker hub. Run the WebAssembly-based image from Docker Hub in the Kubernetes cluster as follows.
Since we are using `hostNetwork` in the `kubectl run` command, the HTTP server image is running on the local network with IP address `127.0.0.1`. Now, you can use the `curl` command to access the HTTP service.
130
+
131
+
```bash
132
+
$ curl -d "name=WasmEdge" -X POST http://127.0.0.1:1234
0 commit comments