Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

function-wasm

CI

Caution

Experimental. function-wasm is young: the sandbox hasn’t had an independent security review, and nothing here has run in production yet. From 1.0.0 the Input, the guest ABI, the runtime flags and the rest of what Compatibility lists change only through its deprecation policy; before it they could change between minor releases. Try it, break it and open an issue, but don’t build a platform on it yet.

This page is for Crossplane users deciding whether to run composition logic as WebAssembly modules. It assumes you know Compositions and pipeline mode.

function-wasm is a Crossplane composition function that runs a WebAssembly module in a Wasmtime sandbox. A module follows the contract of a native function, RunFunction(RunFunctionRequest) → RunFunctionResponse. You write an ordinary function, in Go with function-sdk-go or in Rust, Zig, C, TypeScript or Python, compile it to WebAssembly, publish the module and point a Composition step at it.

It fits when a pipeline step’s logic should change without a new Function package, or when the people who maintain that logic aren’t the people who maintain the Composition. One installed function-wasm serves any number of modules, so a new module version is a new reference in the Input.

apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
  name: example
spec:
  compositeTypeRef:
    apiVersion: example.crossplane.io/v1
    kind: XR
  mode: Pipeline
  pipeline:
  - step: greet
    functionRef:
      name: function-wasm
    input:
      apiVersion: wasm.fn.crossplane.io/v1
      kind: Input
      module:
        type: OCI
        oci:
          ref: ghcr.io/example/greeter:v1@sha256:4c9d…  # printed by guestfn push; the digest pins the module, the tag is for humans
      config:
        greeting: hi

The module receives the whole RunFunctionRequest and returns the whole RunFunctionResponse, so desired resources, results, conditions, requirements (extra resources), context and TTL pass through as they do for a native function. The runtime withholds only the step credentials a module wasn’t granted.

Where to go next