Skip to content

chrismacp/envoy-wasm-filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust WebAssembly Envoy Filter

I wanted to check out the status of WebAssembly and see how easy it is to create an Envoy filter. This is what I managed to piece together in August 2021.

The Envoy filter is built using Rust (which I'm new to!) and added to a vanilla version of Envoy v1.19.x.

I followed guidance from these two posts, but more useful links posted at the bottom:

Demo

There is a Docker Compose file which starts up a provider service behind envoy and a consumer service to consume from it.

The provider service checks for an auth token - the aim is to move this to the filter in case you see this before I get that done

Use the Makefile to start it up

Alt text

digraph G { compound=true; rankdir=LR pad="0.2,0.5"
subgraph cluster1 {
  style=filled;
  color=lightgrey;
  node [style=filled,color=white];
  wasmFilter [shape=box, label="WASM Filter"];
  label=<Envoy<BR /><FONT POINT-SIZE="10">:8200</FONT>>;
}

consumer [shape=box, label=<Consumer<BR /><FONT POINT-SIZE="10">:8100</FONT>>];
provider [shape=box, label=<Provider<BR /><FONT POINT-SIZE="10">:8300</FONT>>];

consumer -> wasmFilter [lhead=cluster1];
wasmFilter -> provider [ltail=cluster1];

}

WASM Filter

The filter currently just adds two headers to the requests it handles:

Request Header called 'filter-added'

Response Header called 'filter-added'

Makefile

Run

# build the WASM filter in Rust
make build 

# Deploy the demo 
make start 

Make requests

# Successful request (default role = admin)
http localhost:8100/
curl localhost:8100/

# Unsuccessful request
http localhost:8100/ role==somethingelse
curl localhost:8100/?role=somethingelse

Useful Links

About

Tinkering with Envoy WASM filters

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published