liveBook · Manning

Spin application

As explained in Server-Side WebAssembly

A Spin application is a WebAssembly application packaged and executed with the Spin framework and runtime.

A Spin application packages WebAssembly components for execution by the Spin framework and runtime. For Kubernetes deployment, it is built, published to an OCI registry image, and represented by a SpinApp custom resource that SpinKube can deploy and manage through Kubernetes-native patterns. section 8.2.2 section 8.5

A practical deployment pipeline is:

  • Build the application with spin build. section 8.2.2
  • Push the resulting application as an OCI image to a registry. section 8.2.2
  • Use the Spin kube plugin to scaffold a SpinApp manifest, then apply it to the cluster. section 8.2.2
  • Expose or test the deployed service with Kubernetes tooling such as port forwarding and curl. section 8.2.2

HTTP application scaled by demand

A JavaScript HTTP application can provide ordinary routes plus a deliberately expensive /load route that calculates Fibonacci values. Publishing it and scaffolding with HPA settings creates a SpinApp with CPU and memory requests, limits, and one-to-ten replicas; sustained load lets Kubernetes increase replicas. section 8.2.3

Spin applications let Wasm workloads reuse Kubernetes orchestration, service discovery, load balancing, and autoscaling while relying on SpinKube’s CRDs and operator. This bridges gaps where a Wasm-native operational tool is not available, though it requires the specialized containerd-shim-spin executor. section 8.5 section 8.2.2

Listing 8.4 SpinApp manifest (scaffolded output)
apiVersion: core.spinkube.dev/v1alpha1
kind: SpinApp
metadata:
  name: hello-world-spin
spec:
  image: "ghcr.io/danbugs/serverside-wasm-book-code/hello-world-spin:latest"
  executor: containerd-shim-spin
  replicas: 2

The scaffolded SpinApp manifest shows the registry image, Spin executor, and desired replica count that define a deployed application. section 8.2.2

How Server-Side WebAssembly covers it

How deep it goes
Walks through building, registry publishing, manifest scaffolding, testing, and HPA-based scaling; defers basic application creation.
Examples
Uses a Rust hello-world HTTP handler and a JavaScript router with a CPU-intensive Fibonacci /load endpoint.
What it assumes
Assumes a configured Kubernetes cluster, ready Spin operator, registry authentication, and Rust 1.85.0 or later for the Rust example.
What you can do after
Operate/configure it by publishing an app, generating a SpinApp resource, deploying it, and enabling HPA scaling.
How it connects
Connects SpinKube, Kubernetes, OCI images, SpinApp, Horizontal Pod Autoscaler, and WebAssembly.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Server-Side WebAssembly. The section links point to the parts of the book it draws on.