schemaVersion: 1
name: <your-extension>
description: <description>
version: 1.0.0
phase: PreAuthZ
priority: 100
module: extension.wasm
You can use WebAssembly extensions to add new features directly into the Maistra Service Mesh proxies, allowing you to move even more common functionality out of your applications, and implement them in a single language that compiles to WebAssembly bytecode.
WebAssembly modules can be run on many platforms, including proxies, and has broad language support, fast execution and a sandboxed-by-default security model.
Maistra Service Mesh extensions are Envoy HTTP Filters, giving them a wide range of capabilities:
Manipulating the body and headers of requests and responses
Out-of-band HTTP requests to services not in the request path, such as authentication or policy checking
Side-channel data storage and queues for filters to communicate with each other
There are two parts to writing a Maistra Service Mesh 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.
You can use any language that compiles to WebAssembly bytecode to write a Maistra Service Mesh extension, but the following languages have existing SDKs that expose the proxy-wasm API so that it can be consumed directly.
Language | Maintainer | Repository |
---|---|---|
AssemblyScript |
solo.io |
|
C++ |
proxy-wasm team (Istio Community) |
|
Go |
tetrate.io |
|
Rust |
proxy-wasm team (Istio Community) |
You must have a .wasm
file containing the bytecode of your WebAssembly module, and a manifest.yaml
file in the root of the container filesystem to make your container image a valid extension image.
schemaVersion: 1
name: <your-extension>
description: <description>
version: 1.0.0
phase: PreAuthZ
priority: 100
module: extension.wasm
Field | Description |
---|---|
schemaVersion |
Used for versioning of the manifest schema. Currently the only possible value is |
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. This is a required field. |
priority |
The default priority of your extension. This is a required field. |
module |
The relative path from the container filesystem’s root to your WebAssembly module. This is a required field. |
For a complete example that was built using the Rust SDK, take a look at the header-append-filter. It is a simple filter that appends one or more headers to the HTTP responses, with their names and values taken out from the config
field of the extension. See a sample configuration in the snippet below.
Maistra Service Mesh extensions can be enabled using the ServiceMeshExtension
resource. In this example, istio-system
is the name of the control plane project.
Create the following example resource:
apiVersion: maistra.io/v1
kind: ServiceMeshExtension
metadata:
name: header-append
namespace: istio-system
spec:
workloadSelector:
labels:
app: httpbin
config:
first-header: some-value
another-header: another-value
image: quay.io/maistra-dev/header-append-filter:2.1
phase: PostAuthZ
priority: 100
Apply the extension.yaml
file with the following command:
$ oc apply -f extension.yaml
Field | Description |
---|---|
metadata.namespace |
The |
spec.workloadSelector |
The |
spec.config |
This is a structured field that will be handed over to the extension, with the semantics dependent on the extension you are deploying. |
spec.image |
A container image URI pointing to the image that holds the extension. |
spec.phase |
This field defaults to the value set in the |
spec.priority |
If multiple extensions with the same |