docs/root/intro/arch_overview/advanced/dynamic_modules.rst
.. _arch_overview_dynamic_modules:
.. attention::
The dynamic modules feature is currently under active development. Capabilities will be expanded over time and it still lacks some features that are available in other extension mechanisms. We are looking for feedback from the community to improve the feature.
Envoy has support for loading shared libraries at runtime to extend its functionality. In Envoy, these are known as "dynamic modules." More specifically, dynamic modules are shared libraries that implement the
:repo:ABI <source/extensions/dynamic_modules/abi/abi.h> written in a pure C header file. The ABI defines a set of functions
that the dynamic module must implement to be loaded by Envoy. Also, it specifies the functions implemented by Envoy
that the dynamic module can call to interact with Envoy.
Implementing the ABI from scratch requires an extensive understanding of the Envoy internals. For users, we provide an official SDK that abstracts these details and provides a high-level API to implement dynamic modules. The SDK is currently available in C++, Go, and Rust. In theory, any language that can produce a shared library can be used to implement dynamic modules. Future development may include support for other languages.
Currently, dynamic modules are supported at the following extension points:
bootstrap extension <envoy_v3_api_msg_extensions.bootstrap.dynamic_modules.v3.DynamicModuleBootstrapExtension>.cluster <envoy_v3_api_msg_extensions.clusters.dynamic_modules.v3.ClusterConfig>.listener filter <envoy_v3_api_msg_extensions.filters.listener.dynamic_modules.v3.DynamicModuleListenerFilter>.UDP listener filter <envoy_v3_api_msg_extensions.filters.udp.dynamic_modules.v3.DynamicModuleUdpListenerFilter>.access logger <envoy_v3_api_msg_extensions.access_loggers.dynamic_modules.v3.DynamicModuleAccessLog>.network filter <envoy_v3_api_msg_extensions.filters.network.dynamic_modules.v3.DynamicModuleNetworkFilter>.HTTP filter <envoy_v3_api_msg_extensions.filters.http.dynamic_modules.v3.DynamicModuleFilter>.HTTP matching data input <envoy_v3_api_msg_extensions.matching.http.dynamic_modules.v3.HttpDynamicModuleMatchInput>.input matcher <envoy_v3_api_msg_extensions.matching.input_matchers.dynamic_modules.v3.DynamicModuleMatcher>.TLS certificate validator <envoy_v3_api_msg_extensions.transport_sockets.tls.cert_validator.dynamic_modules.v3.DynamicModuleCertValidatorConfig>.load balancing policy <envoy_v3_api_msg_extensions.load_balancing_policies.dynamic_modules.v3.DynamicModulesLoadBalancerConfig>.upstream HTTP TCP bridge <envoy_v3_api_msg_extensions.upstreams.http.dynamic_modules.v3.Config>.tracer <envoy_v3_api_msg_extensions.tracers.dynamic_modules.v3.DynamicModuleTracer>.There are a few design goals for the dynamic modules:
Since a dynamic module is loaded at runtime, it must be ABI-compatible with the Envoy binary that loads it.
Envoy's dynamic modules have stricter compatibility requirements than Envoy's other extension mechanisms, such as Lua, Wasm or External Processor. Stabilizing the ABI is challenging due to the way the ABI needs to be tightly coupled to Envoy's internals.
Currently, we guarantee forward compatibility within one version: a dynamic module built with the SDK for Envoy version X.Y will work with Envoy versions X.Y and X.(Y+1). Breaking changes to the ABI may occur in later versions.
To ensure compatibility, it is recommended to rebuild your dynamic modules with the SDK matching your target Envoy version in a timely manner.
A dynamic module is referenced by its name as in the :ref:configuration API <envoy_v3_api_msg_extensions.dynamic_modules.v3.DynamicModuleConfig>.
The name is used to search for the shared library file in the search path. The search path is configured by the environment variable
ENVOY_DYNAMIC_MODULES_SEARCH_PATH. The actual search path is ${ENVOY_DYNAMIC_MODULES_SEARCH_PATH}/lib${name}.so. If
the environment variable is not set, the current working directory is used instead. After searching in the specified search path,
the standard library paths such as LD_LIBRARY_PATH and /usr/lib are searched as well following the behavior of dlopen(3).
For example, when the name my_module is referenced in the configuration and ENVOY_DYNAMIC_MODULES_SEARCH_PATH is set to /path/to/modules,
Envoy will first look for /path/to/modules/libmy_module.so, then $LD_LIBRARY_PATH/libmy_module.so, and finally /usr/lib/libmy_module.so, etc.
The dynamic modules should be used under the assumption that all modules are fully trusted and have the same privilege level as the main Envoy program. Since these modules run in the same process as Envoy, they can access all memory and resources available to the main process. This makes it unfeasible to enforce security boundaries between Envoy and the modules, as they share the same address space and permissions. It is essential that any dynamic module undergo thorough testing and validation before deployment just like any other application code.
The Rust SDK provides an optional CatchUnwind wrapper that can be used to wrap
filter implementations. When a wrapped callback panics, the SDK logs the panic payload
and returns a fail-closed default:
StopIteration.StopIteration.StopIteration.StopIteration.When CatchUnwind is applied to a filter, this prevents a single panicking module
from aborting the entire Envoy process. The affected request or connection is
terminated; other traffic is unaffected.
We have a dedicated repository for the dynamic module examples to help you get started.
The repository is available at envoyproxy/dynamic-modules-examples <https://github.com/envoyproxy/dynamic-modules-examples>_