Skip to content

Commit f7d3dde

Browse files
lxfontesjoonas
andauthored
chore: Update Example Setup (#70)
--------- Signed-off-by: Lucas Fontes <lucas@cosmonic.com> Signed-off-by: Lucas Fontes <lxfontes@gmail.com> Co-authored-by: Joonas Bergius <joonas@users.noreply.github.com>
1 parent e6de0f9 commit f7d3dde

File tree

8 files changed

+258
-58
lines changed

8 files changed

+258
-58
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ spec:
1818
# The number of wasmCloud host pods to run
1919
hostReplicas: 2
2020
# The lattice to connect the hosts to
21-
lattice: 83a5b52e-17cf-4080-bac8-f844099f142e
21+
lattice: default
2222
# Additional labels to apply to the host other than the defaults set in the operator
2323
hostLabels:
2424
some-label: value
2525
# The address to connect to nats
26-
natsAddress: nats://nats-cluster.default.svc.cluster.local
26+
natsAddress: nats://nats.default.svc.cluster.local
2727
# Which wasmCloud version to use
28-
version: 1.0.2
28+
version: 1.0.4
2929
# Enable the following to run the wasmCloud hosts as a DaemonSet
3030
#daemonset: true
3131
# The name of the image pull secret to use with wasmCloud hosts so that they
@@ -121,7 +121,7 @@ config:
121121

122122
```sh
123123
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
124-
helm upgrade --install -f values.yaml nats-cluster nats/nats
124+
helm upgrade --install -f values.yaml nats nats/nats
125125
```
126126

127127
### Running Wadm
@@ -133,7 +133,7 @@ NATS server deployed above, all you need in your `values.yaml` file is:
133133
wadm:
134134
config:
135135
nats:
136-
server: "nats-cluster.default.svc.cluster.local:4222"
136+
server: "nats.default.svc.cluster.local:4222"
137137
```
138138

139139
You can deploy Wadm using your values file and Helm:
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
apiVersion: k8s.wasmcloud.dev/v1alpha1
2+
kind: WasmCloudHostConfig
3+
metadata:
4+
name: my-wasmcloud-cluster
5+
namespace: default
6+
spec:
7+
# Optional: Number of hosts (pods). Defaults to 1.
8+
hostReplicas: 1
9+
# Required: The lattice to connect the hosts to.
10+
lattice: default
11+
# Optional: Additional labels to apply to the host other than the defaults set in the controller.
12+
hostLabels:
13+
test: value
14+
cluster: kind
15+
# Required: Which wasmCloud version to use.
16+
version: "1.0.4"
17+
# Optional: The image to use for the wasmCloud host.
18+
# If provided, the 'version' field will be ignored.
19+
image: "registry/wasmcloud:tag"
20+
# Optional: The image to use for the NATS leaf that is deployed alongside the wasmCloud host.
21+
# If not provided, the default upstream image will be used.
22+
natsLeafImage: "registry/nats:tag"
23+
# Optional. The name of a secret containing a set of NATS credentials under 'nats.creds' key.
24+
secretName: "wasmcloud-host-nats-secret"
25+
# Optional: Enable structured logging for host logs. Defaults to "false".
26+
enableStructuredLogging: true
27+
# Optional: The name of a secret containing the registry credentials.
28+
# See https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-by-providing-credentials-on-the-command-line
29+
registryCredentialsSecret: "wasmcloud-pull-secret"
30+
# Optional: The control topic prefix to use for the host. Defaults to "wasmbus.ctl"
31+
controlTopicPrefix: "wasmbus.custom-ctl"
32+
# Optional: The leaf node domain to use for the NATS sidecar. Defaults to "leaf".
33+
leafNodeDomain: "custom-leaf"
34+
# Optional: Enable the config service for this host. Defaults to "false".
35+
# Makes wasmCloud host issue requests to a config service on startup.
36+
configServiceEnabled: true
37+
# Optional: The log level to use for the host. Defaults to "INFO".
38+
logLevel: INFO
39+
# Optional: The address of the NATS server to connect to. Defaults to "nats://nats.default.svc.cluster.local".
40+
natsAddress: nats://nats.default.svc.cluster.local
41+
# Optional: Allow the host to deploy using the latest tag on OCI components or providers. Defaults to "false".
42+
allowLatest: true
43+
# Optional: Allow the host to pull artifacts from OCI registries insecurely.
44+
allowedInsecure:
45+
- "localhost:5001"
46+
- "kind-registry:5000"
47+
# Optional: Policy service configuration.
48+
policyService:
49+
# If provided, enables policy checks on start actions and component invocations.
50+
topic: "wasmcloud.policy"
51+
# If provided, allows the host to subscribe to updates on past policy decisions. Requires 'topic' above to be set.
52+
changesTopic: "wasmcloud.policy.changes"
53+
# If provided, allows setting a custom timeout for requesting policy decisions. Defaults to 1000. Requires 'topic' to be set.
54+
timeoutMs: 10000
55+
# Optional: Observability options for configuring the OpenTelemetry integration.
56+
observability:
57+
# NOTE: Enables all signals (logs/metrics/traces) at once. Set it to 'false' and enable each signal individually in case you don't need all of them.
58+
enable: true
59+
endpoint: "otel-collector.svc"
60+
# Either 'grpc' or 'http'
61+
protocol: "http"
62+
logs:
63+
enable: false
64+
endpoint: "logs-specific-otel-collector.svc"
65+
metrics:
66+
enable: false
67+
endpoint: "metrics-specific-otel-collector.svc"
68+
traces:
69+
enable: false
70+
endpoint: "traces-specific-otel-collector.svc"
71+
# Optional: Additional options to control how the underlying wasmCloud hosts are scheduled in Kubernetes.
72+
# This includes setting resource requirements for the nats and wasmCloud host
73+
# containers along with any additional pot template settings.
74+
schedulingOptions:
75+
# Optional: Enable the following to run the wasmCloud hosts as a DaemonSet. Defaults to "false".
76+
daemonset: true
77+
# Optional: Set the resource requirements for the nats and wasmCloud host containers.
78+
# See https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ for valid values
79+
resources:
80+
nats:
81+
requests:
82+
cpu: "1"
83+
wasmCloudHost:
84+
requests:
85+
cpu: "1"
86+
# Optional: Any additional pod template settings to apply to the wasmCloud host pods.
87+
# See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#podspec-v1-core for all valid options.
88+
# Note that you *cannot* set the `containers` field here as it is managed by the controller.
89+
podTemplateAdditions:
90+
spec:
91+
nodeSelector:
92+
kubernetes.io/os: linux

examples/quickstart/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Example setup
2+
3+
This example shows the bare minimum requirements to deploy applications on wasmCloud.
4+
5+
It relies on the Kubernetes `default` namespace for simplicity.
6+
7+
## Install [NATS](https://github.com/nats-io/nats-server)
8+
9+
```bash
10+
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
11+
helm upgrade --install -f nats-values.yaml nats nats/nats
12+
```
13+
14+
Validate installation with:
15+
16+
```bash
17+
# make sure pods are ready
18+
kubectl rollout status deploy,sts -l app.kubernetes.io/instance=nats
19+
```
20+
21+
## Install wasmCloud Application Deployment Manager - [wadm](https://github.com/wasmCloud/wadm)
22+
23+
```sh
24+
helm install wadm -f wadm-values.yaml oci://ghcr.io/wasmcloud/charts/wadm
25+
```
26+
27+
Validate installation with:
28+
29+
```bash
30+
# make sure pods are ready
31+
kubectl rollout status deploy -l app.kubernetes.io/instance=wadm
32+
```
33+
34+
## Install the operator
35+
36+
```sh
37+
kubectl apply -k ../../deploy/base
38+
```
39+
40+
Validate installation with:
41+
42+
```bash
43+
# make sure pods are ready
44+
kubectl rollout status deploy -l app=wasmcloud-operator -n wasmcloud-operator
45+
# apiservice should be available
46+
kubectl get apiservices.apiregistration.k8s.io v1beta1.core.oam.dev
47+
```
48+
49+
## Create wasmcloud cluster
50+
51+
```bash
52+
kubectl apply -f wasmcloud-host.yaml
53+
```
54+
55+
Check wasmCloud host status with:
56+
57+
```bash
58+
kubectl describe wasmcloudhostconfig wasmcloud-host
59+
```
60+
61+
## Managing applications using kubectl
62+
63+
Install the rust hello world application:
64+
65+
```bash
66+
kubectl apply -f hello-world-application.yaml
67+
```
68+
69+
Check application status with:
70+
71+
```bash
72+
kubectl get applications
73+
```
74+
75+
## Managing applications with wash
76+
77+
Port forward into the NATS cluster. 4222 = NATS Service, 4223 = NATS Websockets
78+
79+
```bash
80+
kubectl port-forward svc/nats 4222:4222 4223:4223
81+
```
82+
83+
In another shell:
84+
85+
```bash
86+
wash app list
87+
```
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
apiVersion: core.oam.dev/v1beta1
2+
kind: Application
3+
metadata:
4+
name: hello-world
5+
annotations:
6+
version: v0.0.1
7+
description: "HTTP hello world demo in Rust, using the WebAssembly Component Model and WebAssembly Interfaces Types (WIT)"
8+
wasmcloud.dev/authors: wasmCloud team
9+
wasmcloud.dev/source-url: https://github.com/wasmCloud/wasmCloud/blob/main/examples/rusg/components/http-hello-world/wadm.yaml
10+
wasmcloud.dev/readme-md-url: https://github.com/wasmCloud/wasmCloud/blob/main/examples/rusg/components/http-hello-world/README.md
11+
wasmcloud.dev/homepage: https://github.com/wasmCloud/wasmCloud/tree/main/examples/rusg/components/http-hello-world
12+
wasmcloud.dev/categories: |
13+
http,http-server,rust,hello-world,example
14+
spec:
15+
components:
16+
- name: http-component
17+
type: component
18+
properties:
19+
image: ghcr.io/wasmcloud/components/http-hello-world-rust:0.1.0
20+
traits:
21+
# Govern the spread/scheduling of the component
22+
- type: spreadscaler
23+
properties:
24+
replicas: 1
25+
26+
# Add a capability provider that enables HTTP access
27+
- name: httpserver
28+
type: capability
29+
properties:
30+
image: ghcr.io/wasmcloud/http-server:0.21.0
31+
traits:
32+
# Establish a unidirectional link from this http server provider (the "source")
33+
# to the `http-component` component (the "target") so the component can handle incoming HTTP requests,
34+
#
35+
# The source (this provider) is configured such that the HTTP server listens on 127.0.0.1:8080
36+
- type: link
37+
properties:
38+
target: http-component
39+
namespace: wasi
40+
package: http
41+
interfaces: [incoming-handler]
42+
source_config:
43+
- name: default-http
44+
properties:
45+
address: 127.0.0.1:8080
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
config:
2+
cluster:
3+
enabled: true
4+
replicas: 3
5+
leafnodes:
6+
enabled: true
7+
websocket:
8+
enabled: true
9+
port: 4223
10+
jetstream:
11+
enabled: true
12+
fileStore:
13+
pvc:
14+
size: 10Gi
15+
merge:
16+
domain: default
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
wadm:
2+
image:
3+
tag: v0.12.2
4+
config:
5+
nats:
6+
server: "nats.default.svc.cluster.local:4222"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: k8s.wasmcloud.dev/v1alpha1
2+
kind: WasmCloudHostConfig
3+
metadata:
4+
name: wasmcloud-host
5+
spec:
6+
lattice: default
7+
version: "1.0.4"

sample.yaml

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)