Golang

The Golang network filter allows Golang to be run during both the downstream and upstream tcp data flows and makes it easier to extend Envoy.

Go plugins used by this filter can be recompiled independently of Envoy.

See the Envoy’s Golang extension proposal documentation for more details on the filter’s implementation.

Warning

The Envoy Golang filter is designed to be run with the GODEBUG=cgocheck=0 environment variable set.

This disables the cgo pointer check.

Failure to set this environment variable will cause Envoy to crash!

Developing a Go plugin

Envoy’s Go plugins must implement the DownstreamFilter/UpstreamFilter API.

Building a Go plugin

Attention

When building a Go plugin dynamic library, you must use a Go version consistent with Envoy’s version of glibc.

One way to ensure a compatible Go version is to use the Go binary provided by Envoy’s bazel setup:

$ bazel run @go_sdk//:bin/go -- version
...
go version goX.YZ linux/amd64

For example, to build the .so for a foo plugin, you might run:

$ bazel run @go_sdk//:bin/go build --buildmode=c-shared  -v -o path/to/output/libfoo.so path/to/src/foo

Configuration

Tip

This filter should be configured with the type URL type.googleapis.com/envoy.extensions.filters.http.golang.v3alpha.Config.

A prebuilt Golang network filter my_plugin.so might be configured as follows:

10      - name: envoy.filters.network.golang
11        typed_config:
12          "@type": type.googleapis.com/envoy.extensions.filters.network.golang.v3alpha.Config
13          is_terminal_filter: true
14          library_id: simple
15          library_path: "/lib/simple.so"
16          plugin_name: simple
17          plugin_config:
18            "@type": type.googleapis.com/xds.type.v3.TypedStruct
19            value:
20              echo_server_addr: echo_service