Lua cluster specifier

In this example, we show how the Lua cluster specifier can be used with the Envoy proxy.

The example Envoy proxy configuration includes a Lua cluster specifier plugin that contains a function:

  • envoy_on_route(route_handle)


See the Lua cluster configuration documentation for an overview and documentation regarding the function.

Step 1: Build the sandbox

Change to the examples/lua-cluster-specifier directory, and bring up the composition.

$ pwd
$ docker compose pull
$ docker compose up --build -d
$ docker compose ps

Name                                  Command                        State   Ports
lua-cluster-specifier-proxy-1         / /usr ... Up      10000/tcp,>10000/tcp

Step 2: Send a request to the normal service

The output from the curl command below should return 200, since the lua code select the normal service.

$ curl -i localhost:10000/anything 2>&1 |grep 200
HTTP/1.1 200 OK

Step 3: Send a request to the fake service

If you specify the request header header_key:fake, curl will return a 503 response, as the Lua code will select the fake service.

$ curl -i localhost:8000/anything -H "header_key:fake" 2>&1 |grep 503
HTTP/1.1 503 Service Unavailable

See also

Envoy Lua cluster specifier

Learn more about the Envoy Lua cluster specifier.


The Lua programming language.