Skip to main content
Version: 1.x

Applications

Overview

Applications combine all of the previous concepts into a declarative, deployable unit.

Applications are the primary abstraction for deployable workloads in a wasmCloud lattice. Applications are declared, versioned, and defined using application manifests. Manifests conform to the OAM manifest standard and may be written in YAML or JSON.

Once deployed, applications are represented as models in the wasmCloud Application Deployment Manager (Wadm). An application model may include multiple deployable versions. Model persistence is decoupled from deployments themselves and from any particular host.

Compared to Kubernetes...

A wasmCloud application is analogous to a Kubernetes Deployment.

Application manifests

wasmCloud application manifests are composed of two sections: metadata and spec.

  • The metadata contains the application's name, version, and description.
  • The spec contains a list of the application's components and providers, each of which can have traits. Traits define configuration for the component, links, and how the component should be deployed. Examples of deployment traits include:
  • run a single instance on a specific host foo
  • run N instances on each host in the lattice
  • 80% on hosts with label foo, 20% on hosts with label bar

The following is an example of a simple wasmCloud application manifest:

yaml
# Metadata
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: hello-world
  annotations:
    description: 'HTTP hello world demo'
spec:
  components:
    - name: http-component
      type: component
      properties:
        # Run components from OCI registries as below or from a local .wasm component binary.
        image: ghcr.io/wasmcloud/components/http-hello-world-rust:0.1.0
      traits:
        # One replica of this component will run
        - type: spreadscaler
          properties:
            instances: 1
    # The httpserver capability provider, started from the official wasmCloud OCI artifact
    - name: httpserver
      type: capability
      properties:
        image: ghcr.io/wasmcloud/http-server:0.22.0
      traits:
        # Link the HTTP server and set it to listen on the local machine's port 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
Write less YAML

The design of WebAssembly Interface Type (WIT) interfaces makes it possible to automate the generation of a manifest for a given component. Use the wit2wadm tool to quickly generate manifests from your components on the command line.

wasmCloud Application Deployment Manager (wadm)

Application deployment and management is handled by the wasmCloud Application Deployment Manager (wadm), a part of the wasmCloud platform that uses a control loop to react to events and reconcile requested state with desired state.

For an in-depth guide on how wasmCloud manages applications, see wasmCloud Application Deployment Manager.

Imperative or declarative?

While wasmCloud supports the imperative management of components, providers, and links (which can be useful for experimentation or debuggging), these are generally considered low-level operations. Declarative application management is generally better-suited to complex distributed applications that can be dynamically adjusted at runtime.

Application models are stored in a NATS key-value bucket and persist beyond a particular host. For more information on how Wadm handles models, see the reference for the Wadm API.

The application lifecycle

The diagrams below demonstrate the sequence of invocations for a variety of wasmCloud applications.

Invocation lifecycle: Application with http interface

Invocation lifecycle: Application with http and key-value interfaces

Invocation lifecycle: Component at runtime