Skip to content

Commit

Permalink
Complete Readme.md
Browse files Browse the repository at this point in the history
Signed-off-by: kanishkarj <[email protected]>
  • Loading branch information
kanishkarj committed May 10, 2020
1 parent febfa3b commit ca05258
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 6 deletions.
100 changes: 95 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,98 @@
# WASM Filters

This repository contains various sample WASM filters.
This repository contains WASM filters in rust exercising different features provided by envoy-wasm.

Filters :
- TCP-Metrics : (On going)
- HTTP-Cache : (Todo)
- Interservice latency : (Todo)
## Upstream

Upstream is a webserver which is used by few of the filters mentioned above. It provides a route for :

* Mock authentication
* Storing Metrics
* Retrieving Metrics

> Build the docker Image for Upstream before proceeding with the examples.
Build Image:
```bash
cd upstream
make
```

## HTTP-Auth

Simulates handling authentication of requests at proxy level. Requests with a header `token` with value `hello` are accepted as authorized while the rest unauthorized. The actual authentication is handled by the Upstream server. Whenever the proxy recieves a request it extracts the `token` header and makes a request to the Upstream server which validates the token and returns a response.

Deploy:
```bash
cd http-auth
make deploy-filtered
```

Test:
```bash
curl -H "token":"hello" 0.0.0.0:18000 -v # Authorized
curl -H "token":"world" 0.0.0.0:18000 -v # Unauthorized
```

## TCP-Metrics

Collects simple metrics for every TCP packet and logs it.

Deploy:
```bash
cd tcp-metrics
make deploy-filtered
```

Test:
```bash
curl -H 0.0.0.0:18000 -v -d "request body"
```

Check the logs for the metrics.

## TCP-Packet-Parse

Parses the contents of every TCP packet the proxy recieves and logs it.

Deploy:
```bash
cd tcp-packet-parse
make deploy-filtered
```

Test:
```bash
curl -H 0.0.0.0:18000 -v -d "request body"
```

Check the logs for the packet contents.

## Singleton-HTTP-Call

An example which depicts an singleton HTTP WASM service which does an HTTP call once every 2 seconds.

Deploy:
```bash
cd singleton-http-call
make deploy-filtered
```

Check the logs for the response of the request.

## Metrics-Store

This example showcases communication between a WASM filter and a service via shared queue. It combines the `Singleton-HTTP-Call` and `TCP-Metrics` examples. The filter collects metrics and enqueues it onto the queue while the service dequeues it and sends it to upstream server where it is stored.

Deploy:
```bash
cd metrics-store
make deploy-filtered
```

Test:
```bash
curl 0.0.0.0:18000 -v -d "request body" # make a few of these calls
curl 0.0.0.0:8080/retrieve -v # Retrieves the stored stats
# x | y | z === x : downstream bytes, y : upstream bytes, z: the latency for application server to respond
```
1 change: 1 addition & 0 deletions http-auth/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build:
deploy:
docker-compose up --build --remove-orphans

# shows only the logs related to WASM filter/singleton
deploy-filtered:
docker-compose up --build --remove-orphans | grep "\[wasm\]\|Starting"

Expand Down
1 change: 1 addition & 0 deletions metrics-store/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ build:
deploy:
docker-compose up --build --remove-orphans

# shows only the logs related to WASM filter/singleton
deploy-filtered:
docker-compose up --build --remove-orphans | grep "\[wasm\]\|Starting"

Expand Down
1 change: 1 addition & 0 deletions singleton-http-call/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build:
deploy:
docker-compose up --build --remove-orphans

# shows only the logs related to WASM filter/singleton
deploy-filtered:
docker-compose up --build --remove-orphans | grep "\[wasm\]\|Starting"

Expand Down
1 change: 1 addition & 0 deletions tcp-metrics/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build:
deploy:
docker-compose up --build --remove-orphans

# shows only the logs related to WASM filter/singleton
deploy-filtered:
docker-compose up --build --remove-orphans | grep "\[wasm\]\|Starting"

Expand Down
1 change: 1 addition & 0 deletions tcp-packet-parse/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build:
deploy:
docker-compose up --build --remove-orphans

# shows only the logs related to WASM filter/singleton
deploy-filtered:
docker-compose up --build --remove-orphans | grep "\[wasm\]\|Starting"

Expand Down
5 changes: 4 additions & 1 deletion upstream/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
default:
docker build -t wasm-upstream .
docker build -t wasm-upstream .

get-metrics:
curl 0.0.0.0:8080/retrieve -v

0 comments on commit ca05258

Please sign in to comment.