Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update Example Setup #70

Merged
merged 10 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions examples/full-config/wasmcloud-annotated.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
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.2"
lxfontes marked this conversation as resolved.
Show resolved Hide resolved
# 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-cluster.default.svc.cluster.local
lxfontes marked this conversation as resolved.
Show resolved Hide resolved
# 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: "bar"
lxfontes marked this conversation as resolved.
Show resolved Hide resolved
# 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:
enable: true
endpoint: "otel-collector.svc"
# Either 'grpc' or 'http'
protocol: "grpc"
lxfontes marked this conversation as resolved.
Show resolved Hide resolved
logs:
enable: true
lxfontes marked this conversation as resolved.
Show resolved Hide resolved
endpoint: "logs-specific-otel-collector.svc"
metrics:
enable: true
lxfontes marked this conversation as resolved.
Show resolved Hide resolved
endpoint: "metrics-specific-otel-collector.svc"
traces:
enable: true
lxfontes marked this conversation as resolved.
Show resolved Hide resolved
endpoint: "metrics-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: 100m
lxfontes marked this conversation as resolved.
Show resolved Hide resolved
wasmCloudHost:
requests:
cpu: 100m
lxfontes marked this conversation as resolved.
Show resolved Hide resolved
# 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-cluster nats/nats
lxfontes marked this conversation as resolved.
Show resolved Hide resolved
```

Validate installation with:

```bash
# make sure pods are ready
kubectl get statefulset,deployment -l app.kubernetes.io/instance=nats-cluster
lxfontes marked this conversation as resolved.
Show resolved Hide resolved
```

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

```sh
helm install wadm -f wadm-values.yaml --version 0.2.0 oci://ghcr.io/wasmcloud/charts/wadm
lxfontes marked this conversation as resolved.
Show resolved Hide resolved
```

Validate installation with:

```bash
# make sure pods are ready
kubectl get deploy wadm
lxfontes marked this conversation as resolved.
Show resolved Hide resolved
```

## Install the operator

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

Validate installation with:

```bash
# make sure pods are ready
kubectl -n wasmcloud-operator get deploy
lxfontes marked this conversation as resolved.
Show resolved Hide resolved
# 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-cluster 4222:4222 4223:4223
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we switch the helm NATS deployment name from nats-cluster to nats, this would be updated to:

Suggested change
kubectl port-forward svc/nats-cluster 4222:4222 4223:4223
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-cluster.default.svc.cluster.local:4222"
lxfontes marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 8 additions & 0 deletions examples/quickstart/wasmcloud-host.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: k8s.wasmcloud.dev/v1alpha1
kind: WasmCloudHostConfig
metadata:
name: wasmcloud-host
spec:
lattice: default
version: "1.0.4"
natsAddress: nats://nats-cluster.default.svc.cluster.local
lxfontes marked this conversation as resolved.
Show resolved Hide resolved
53 changes: 0 additions & 53 deletions sample.yaml

This file was deleted.

Loading