Skip to content

Commit

Permalink
chore: Update Example Setup (#70)
Browse files Browse the repository at this point in the history
---------

Signed-off-by: Lucas Fontes <[email protected]>
Signed-off-by: Lucas Fontes <[email protected]>
Co-authored-by: Joonas Bergius <[email protected]>
  • Loading branch information
lxfontes and joonas authored Jul 22, 2024
1 parent e6de0f9 commit f7d3dde
Show file tree
Hide file tree
Showing 8 changed files with 258 additions and 58 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ spec:
# The number of wasmCloud host pods to run
hostReplicas: 2
# The lattice to connect the hosts to
lattice: 83a5b52e-17cf-4080-bac8-f844099f142e
lattice: default
# Additional labels to apply to the host other than the defaults set in the operator
hostLabels:
some-label: value
# The address to connect to nats
natsAddress: nats://nats-cluster.default.svc.cluster.local
natsAddress: nats://nats.default.svc.cluster.local
# Which wasmCloud version to use
version: 1.0.2
version: 1.0.4
# Enable the following to run the wasmCloud hosts as a DaemonSet
#daemonset: true
# The name of the image pull secret to use with wasmCloud hosts so that they
Expand Down Expand Up @@ -121,7 +121,7 @@ config:

```sh
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
helm upgrade --install -f values.yaml nats-cluster nats/nats
helm upgrade --install -f values.yaml nats nats/nats
```

### Running Wadm
Expand All @@ -133,7 +133,7 @@ NATS server deployed above, all you need in your `values.yaml` file is:
wadm:
config:
nats:
server: "nats-cluster.default.svc.cluster.local:4222"
server: "nats.default.svc.cluster.local:4222"
```

You can deploy Wadm using your values file and Helm:
Expand Down
92 changes: 92 additions & 0 deletions examples/full-config/wasmcloud-annotated.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
apiVersion: k8s.wasmcloud.dev/v1alpha1
kind: WasmCloudHostConfig
metadata:
name: my-wasmcloud-cluster
namespace: default
spec:
# Optional: Number of hosts (pods). Defaults to 1.
hostReplicas: 1
# Required: The lattice to connect the hosts to.
lattice: default
# Optional: Additional labels to apply to the host other than the defaults set in the controller.
hostLabels:
test: value
cluster: kind
# Required: Which wasmCloud version to use.
version: "1.0.4"
# Optional: The image to use for the wasmCloud host.
# If provided, the 'version' field will be ignored.
image: "registry/wasmcloud:tag"
# Optional: The image to use for the NATS leaf that is deployed alongside the wasmCloud host.
# If not provided, the default upstream image will be used.
natsLeafImage: "registry/nats:tag"
# Optional. The name of a secret containing a set of NATS credentials under 'nats.creds' key.
secretName: "wasmcloud-host-nats-secret"
# Optional: Enable structured logging for host logs. Defaults to "false".
enableStructuredLogging: true
# Optional: The name of a secret containing the registry credentials.
# See https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-by-providing-credentials-on-the-command-line
registryCredentialsSecret: "wasmcloud-pull-secret"
# Optional: The control topic prefix to use for the host. Defaults to "wasmbus.ctl"
controlTopicPrefix: "wasmbus.custom-ctl"
# Optional: The leaf node domain to use for the NATS sidecar. Defaults to "leaf".
leafNodeDomain: "custom-leaf"
# Optional: Enable the config service for this host. Defaults to "false".
# Makes wasmCloud host issue requests to a config service on startup.
configServiceEnabled: true
# Optional: The log level to use for the host. Defaults to "INFO".
logLevel: INFO
# Optional: The address of the NATS server to connect to. Defaults to "nats://nats.default.svc.cluster.local".
natsAddress: nats://nats.default.svc.cluster.local
# Optional: Allow the host to deploy using the latest tag on OCI components or providers. Defaults to "false".
allowLatest: true
# Optional: Allow the host to pull artifacts from OCI registries insecurely.
allowedInsecure:
- "localhost:5001"
- "kind-registry:5000"
# Optional: Policy service configuration.
policyService:
# If provided, enables policy checks on start actions and component invocations.
topic: "wasmcloud.policy"
# If provided, allows the host to subscribe to updates on past policy decisions. Requires 'topic' above to be set.
changesTopic: "wasmcloud.policy.changes"
# If provided, allows setting a custom timeout for requesting policy decisions. Defaults to 1000. Requires 'topic' to be set.
timeoutMs: 10000
# Optional: Observability options for configuring the OpenTelemetry integration.
observability:
# 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.
enable: true
endpoint: "otel-collector.svc"
# Either 'grpc' or 'http'
protocol: "http"
logs:
enable: false
endpoint: "logs-specific-otel-collector.svc"
metrics:
enable: false
endpoint: "metrics-specific-otel-collector.svc"
traces:
enable: false
endpoint: "traces-specific-otel-collector.svc"
# Optional: Additional options to control how the underlying wasmCloud hosts are scheduled in Kubernetes.
# This includes setting resource requirements for the nats and wasmCloud host
# containers along with any additional pot template settings.
schedulingOptions:
# Optional: Enable the following to run the wasmCloud hosts as a DaemonSet. Defaults to "false".
daemonset: true
# Optional: Set the resource requirements for the nats and wasmCloud host containers.
# See https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ for valid values
resources:
nats:
requests:
cpu: "1"
wasmCloudHost:
requests:
cpu: "1"
# Optional: Any additional pod template settings to apply to the wasmCloud host pods.
# See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#podspec-v1-core for all valid options.
# Note that you *cannot* set the `containers` field here as it is managed by the controller.
podTemplateAdditions:
spec:
nodeSelector:
kubernetes.io/os: linux
87 changes: 87 additions & 0 deletions examples/quickstart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Example setup

This example shows the bare minimum requirements to deploy applications on wasmCloud.

It relies on the Kubernetes `default` namespace for simplicity.

## Install [NATS](https://github.com/nats-io/nats-server)

```bash
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
helm upgrade --install -f nats-values.yaml nats nats/nats
```

Validate installation with:

```bash
# make sure pods are ready
kubectl rollout status deploy,sts -l app.kubernetes.io/instance=nats
```

## Install wasmCloud Application Deployment Manager - [wadm](https://github.com/wasmCloud/wadm)

```sh
helm install wadm -f wadm-values.yaml oci://ghcr.io/wasmcloud/charts/wadm
```

Validate installation with:

```bash
# make sure pods are ready
kubectl rollout status deploy -l app.kubernetes.io/instance=wadm
```

## Install the operator

```sh
kubectl apply -k ../../deploy/base
```

Validate installation with:

```bash
# make sure pods are ready
kubectl rollout status deploy -l app=wasmcloud-operator -n wasmcloud-operator
# apiservice should be available
kubectl get apiservices.apiregistration.k8s.io v1beta1.core.oam.dev
```

## Create wasmcloud cluster

```bash
kubectl apply -f wasmcloud-host.yaml
```

Check wasmCloud host status with:

```bash
kubectl describe wasmcloudhostconfig wasmcloud-host
```

## Managing applications using kubectl

Install the rust hello world application:

```bash
kubectl apply -f hello-world-application.yaml
```

Check application status with:

```bash
kubectl get applications
```

## Managing applications with wash

Port forward into the NATS cluster. 4222 = NATS Service, 4223 = NATS Websockets

```bash
kubectl port-forward svc/nats 4222:4222 4223:4223
```

In another shell:

```bash
wash app list
```
45 changes: 45 additions & 0 deletions examples/quickstart/hello-world-application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: hello-world
annotations:
version: v0.0.1
description: "HTTP hello world demo in Rust, using the WebAssembly Component Model and WebAssembly Interfaces Types (WIT)"
wasmcloud.dev/authors: wasmCloud team
wasmcloud.dev/source-url: https://github.com/wasmCloud/wasmCloud/blob/main/examples/rusg/components/http-hello-world/wadm.yaml
wasmcloud.dev/readme-md-url: https://github.com/wasmCloud/wasmCloud/blob/main/examples/rusg/components/http-hello-world/README.md
wasmcloud.dev/homepage: https://github.com/wasmCloud/wasmCloud/tree/main/examples/rusg/components/http-hello-world
wasmcloud.dev/categories: |
http,http-server,rust,hello-world,example
spec:
components:
- name: http-component
type: component
properties:
image: ghcr.io/wasmcloud/components/http-hello-world-rust:0.1.0
traits:
# Govern the spread/scheduling of the component
- type: spreadscaler
properties:
replicas: 1

# Add a capability provider that enables HTTP access
- name: httpserver
type: capability
properties:
image: ghcr.io/wasmcloud/http-server:0.21.0
traits:
# Establish a unidirectional link from this http server provider (the "source")
# to the `http-component` component (the "target") so the component can handle incoming HTTP requests,
#
# The source (this provider) is configured such that the HTTP server listens on 127.0.0.1:8080
- type: link
properties:
target: http-component
namespace: wasi
package: http
interfaces: [incoming-handler]
source_config:
- name: default-http
properties:
address: 127.0.0.1:8080
16 changes: 16 additions & 0 deletions examples/quickstart/nats-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
config:
cluster:
enabled: true
replicas: 3
leafnodes:
enabled: true
websocket:
enabled: true
port: 4223
jetstream:
enabled: true
fileStore:
pvc:
size: 10Gi
merge:
domain: default
6 changes: 6 additions & 0 deletions examples/quickstart/wadm-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
wadm:
image:
tag: v0.12.2
config:
nats:
server: "nats.default.svc.cluster.local:4222"
7 changes: 7 additions & 0 deletions examples/quickstart/wasmcloud-host.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: k8s.wasmcloud.dev/v1alpha1
kind: WasmCloudHostConfig
metadata:
name: wasmcloud-host
spec:
lattice: default
version: "1.0.4"
53 changes: 0 additions & 53 deletions sample.yaml

This file was deleted.

0 comments on commit f7d3dde

Please sign in to comment.