Skip to content

Commit 44ea418

Browse files
committed
[chapter 08] finished other spin example and added wasmcloud k8s yamls
Signed-off-by: danbugs <[email protected]>
1 parent 7364cc6 commit 44ea418

File tree

7 files changed

+3439
-7
lines changed

7 files changed

+3439
-7
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# `hello-world-wasmcloud`
2+
3+
- `wadm.yaml`: includes the `Application` CR to deploy a wasmCloud app to K8s.
4+
- `wasmcloud-host.yaml`: incldues the `WasmCloudHostConfig` CR to dpeloy a wasmCloud host to K8s.
5+
6+
> Note: Usage of both files assumes you've installed the wasmcloud-operator onto your cluster.
7+
8+
Once deployed, port forward the wasmcloud-host deployment and curl the app.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
apiVersion: core.oam.dev/v1beta1
2+
kind: Application
3+
metadata:
4+
name: rust-hello-world
5+
annotations:
6+
description: 'HTTP hello world demo in Rust, using the WebAssembly Component Model and WebAssembly Interfaces Types (WIT)'
7+
spec:
8+
components:
9+
- name: http-component
10+
type: component
11+
properties:
12+
image: ghcr.io/danbugs/serverside-wasm-book-code/hello-world-wasmcloud:v1
13+
traits:
14+
- type: spreadscaler
15+
properties:
16+
instances: 10
17+
- type: link
18+
properties:
19+
namespace: wasi
20+
package: keyvalue
21+
interfaces: [store, atomics]
22+
target:
23+
name: kvnats
24+
config:
25+
- name: wasi-keyvalue-config
26+
properties:
27+
bucket: default
28+
enable_bucket_auto_create: 'true'
29+
30+
- name: httpserver
31+
type: capability
32+
properties:
33+
image: ghcr.io/wasmcloud/http-server:0.23.2
34+
traits:
35+
- type: link
36+
properties:
37+
target: http-component
38+
namespace: wasi
39+
package: http
40+
interfaces: [incoming-handler]
41+
source_config:
42+
- name: default-http
43+
properties:
44+
address: 0.0.0.0:8080
45+
46+
- name: kvnats
47+
type: capability
48+
properties:
49+
image: ghcr.io/wasmcloud/keyvalue-nats:0.3.1
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: k8s.wasmcloud.dev/v1alpha1
2+
kind: WasmCloudHostConfig
3+
metadata:
4+
name: wasmcloud-host
5+
spec:
6+
lattice: default
7+
version: "1.4.1"
8+
hostReplicas: 2

chapter08/scaling-spin/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# `hello-world-spin`
2+
3+
- Pre-reqs:
4+
- K8s cluster w/ the container-spin-shim installed on every node.
5+
- cert-manager installed onto the cluster.
6+
- Spin's RuntimeClass applied.
7+
- Spin's CRDs applied.
8+
- Spin's operator installed.
9+
- Spin's executor created.
10+
11+
- Then, assuming you have `spin` installed, run:
12+
```shell
13+
spin build
14+
spin registry push ghcr.io/<your GH username>/serverside-wasm-book-code/scaling-spin:latest
15+
spin kube scaffold --from ghcr.io/<your GH username>/serverside-wasm-book-code/scaling-spin:latest --autoscaler hpa --cpu-limit 100m --memory-limit 128Mi --cpu-request 50m --memory-request 64Mi --replicas 1 --max-replicas 10 | kubectl create -f –
16+
```
17+
18+
- Then, you can test it with:
19+
```shell
20+
# assuming an ingress controller was applied
21+
oha -c 40 -z 3m -t 5s http://localhost:8081/load
22+
```
Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
{
2-
"version": 1,
3-
"project": {
4-
"worlds": [
5-
"spin-http"
6-
]
7-
},
8-
"packages": {}
2+
"version": 1,
3+
"project": {
4+
"worlds": [
5+
"spin-http"
6+
]
7+
},
8+
"packages": {
9+
"@fermyon/spin-sdk": {
10+
"witPath": "../../bin/wit",
11+
"world": "spin-imports"
12+
}
13+
}
914
}

0 commit comments

Comments
 (0)