Building Extensions

WebAssembly Extension support is in Tech Preview in Maistra 2.0, therefore any API or specs mentioned here are not final and might change before it is Generally Available

There are two parts two writing a Maistra Extension: you’ll have to write your extension using an SDK that exposes the proxy-wasm API and compile it to a WebAssembly module, and then package it into a container.

Supported languages

While theoretically, you’re able to use any language that compiles to WebAssembly bytecode to write a Maistra Extension, the following languages have existing SDKs that expose the proxy-wasm API so that it can be consumed directly:

Language Maintainer Repository

C++

proxy-wasm team (Istio Community)

proxy-wasm/proxy-wasm-cpp-sdk

Rust

proxy-wasm team (Istio Community)

proxy-wasm/proxy-wasm-rust-sdk

AssemblyScript

solo.io

solo-io/proxy-runtime

Go

tetrate.io

tetratelabs/proxy-wasm-go-sdk

This is not meant to be a comprehensive list of all available SDKs, but rather the ones that we have worked with in the past. For usage instructions, please consult the relevant SDK documentation.

Container Format

The only requirements to make any container image a valid Extension image are having two files: your .wasm file containing the bytecode of your WebAssembly module, and a manifest.yaml file in the root of the container filesystem.

manifest.yaml

schemaVersion: 1

name: my-extension
description: A description that outlines what your Extension does
version: 1.0.0
phase: PreAuthZ
priority: 100
module: extension.wasm

Field Reference

schemaVersion

Used for versioning of the manifest schema. Currently the only possible value is 1.

name

The name of your extension. This field is just metadata and currently unused.

description

The description of your extension. This field is just metadata and currently unused.

version

The version of your extension. This field is just metadata and currently unused.

phase

The default execution phase of your Extension. See Using Extensions for details.

This is a required field.

priority

The default priority of your Extension. See Using Extensions for details.

This is a required field.

module

The relative path (from the container filesystem’s root) to your WebAssembly module.

This is a required field.

Other Formats

In the future, we’re planning to also support the WebAssemblyHub container format for Extensions.

Example

For a complete example that was built using the Rust SDK, take a look at the header-append-filter. It is a very simple filter that will simply append a header (custom-header) to all responses, with the value depending on its configuration.