For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
Use a custom Envoy image
Build a custom envoy-wrapper image on top of any upstream Envoy release and point kgateway at it, without waiting for an official kgateway release.
Build a custom envoy-wrapper image on top of any upstream Envoy release and use it in your gateway proxies. For example, this process can be useful to apply CVE fixes that were released upstream, but aren’t yet released in kgateway.
How it works
The kgateway data plane isn’t a plain Envoy binary. It bundles two extra components on top of upstream Envoy:
envoyinit: A Go binary that runs as PID 1, manages the Envoy process lifecycle, and injects bootstrap configuration from xDS.librust_module.so: A Rust dynamic module that powers kgateway’s transformation engine (rustformation) and other data-plane features. Envoy loads this.somodule at startup through its Dynamic Modules API.
Because the Dynamic Modules ABI is tied to a specific Envoy minor version, you can’t swap in a plain upstream Envoy image. Instead, you must build the module and image together. The envoy-wrapper-docker Makefile target handles this: it compiles the Rust module against the Envoy SDK and layers it on top of whatever base image you pass in.
Compatibility
The Rust dynamic module is compiled against the envoy-proxy-dynamic-modules-rust-sdk, which is pinned to the same Envoy version that kgateway targets in a given release. This means:
- Patch-version bumps are safe. The Dynamic Modules ABI is stable within a minor release. If kgateway targets
v1.37.2, you can safely usev1.37.3or any otherv1.37.xpatch. - Minor-version bumps aren’t a simple image swap. Going from
v1.37.xtov1.38.xmeans updating the SDK pin and rebuilding the module. That’s a full Envoy upgrade at the kgateway source level, not something you’d do with this guide.
If you are unsure which Envoy minor version your kgateway release targets, check the ENVOY_IMAGE variable at the top of the project Makefile.
Before you begin
Clone the
kgatewayrepository at the same version as the kgateway control plane running in your cluster. For example, if your cluster runs kgatewayv2.3.0, check out thev2.3.0tag. The Rust module gets compiled from that checkout, so the versions need to line up.git clone https://github.com/kgateway-dev/kgateway.git cd kgateway git checkout v2.3.0Set up a Docker engine with BuildKit /
buildxsupport. For example, you can install the Docker Desktop app.Set up a container registry that your cluster can pull from and connect to it. If your cluster pulls from a private registry, set up image pull secrets on the proxy pods. You can add them with the
podTemplate.imagePullSecretsfield in GatewayParameters.Install
rustup, the Rust toolchain installer. The correct Rust version is then picked up automatically from therust-toolchain.tomlfile in the repository.curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Step 1: Build the wrapper image
Set the following environment variables, then run the build target.
ENVOY_IMAGE: The upstream Envoy image that you want to use as the base image.IMAGE_REGISTRY: Your container registry path. This is where the builtenvoy-wrapperimage gets pushed.VERSION: The image version tag for your custom image, such asv2.3.0-custom. This tag is used to name the output image as$IMAGE_REGISTRY/envoy-wrapper:$VERSION.
Set the environment variables.
export ENVOY_IMAGE=docker.io/envoyproxy/envoy:v1.37.3 export IMAGE_REGISTRY=registry.example.com/myorg export VERSION=v2.3.0-customBuild the custom image.
make envoy-wrapper-dockerUnder the hood, this:
- Builds the Rust dynamic module (
librust_module.so) frominternal/envoy_modules/by usingcargo-zigbuild. - Creates a Dockerfile that sets the
ENVOY_IMAGEas the base image (FROMentry). - Copies the compiled
.solibrary,envoyinitbinary, and entrypoint script to the output directory. - Builds the image with
docker buildx buildand tags the image as$IMAGE_REGISTRY/envoy-wrapper:$VERSION.
By default, the build targets your host architecture. If you’re on an
arm64machine but need anamd64image, setGOARCHexplicitly:GOARCH=amd64 ENVOY_IMAGE=... IMAGE_REGISTRY=... VERSION=... make envoy-wrapper-docker- Builds the Rust dynamic module (
Verify the image is available locally.
docker images registry.example.com/myorg/envoy-wrapperExample output:
REPOSITORY TAG IMAGE ID CREATED SIZE registry.example.com/myorg/envoy-wrapper v2.3.0-custom d3f1a2b3c4e5 1 minute ago 200MB
Step 2: Push the image
docker push registry.example.com/myorg/envoy-wrapper:v2.3.0-customStep 3: Customize the Envoy image
Create a GatewayParameters resource that points spec.kube.envoyContainer.image to your custom wrapper image.
kubectl apply -f- <<EOF
apiVersion: gateway.kgateway.dev/v1alpha1
kind: GatewayParameters
metadata:
name: custom-envoy-image
namespace: kgateway-system
spec:
kube:
envoyContainer:
image:
registry: registry.example.com/myorg
repository: envoy-wrapper
tag: v2.3.0-custom
EOFThe image field follows the same structure used for all container images in kgateway:
| Field | Description |
|---|---|
registry | Container registry hostname, for example registry.example.com/myorg |
repository | Image name, typically envoy-wrapper |
tag | Image tag |
digest | Optional. Use instead of or alongside tag to pin to an exact image digest |
pullPolicy | Optional. Defaults to IfNotPresent |
Step 4: Reference the GatewayParameters from your Gateway
Create or update your Gateway resource to reference the GatewayParameters you just created.
kubectl apply -f- <<EOF
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: my-gateway
namespace: kgateway-system
spec:
gatewayClassName: kgateway
infrastructure:
parametersRef:
group: gateway.kgateway.dev
kind: GatewayParameters
name: custom-envoy-image
listeners:
- name: http
protocol: HTTP
port: 80
allowedRoutes:
namespaces:
from: All
EOFWhen kgateway reconciles this Gateway, it creates a proxy Deployment with the custom image. Existing proxy pods roll over automatically.
Apply to all gateways by default
If you want every Gateway using the kgateway GatewayClass to pick up your custom image automatically, set the gatewayClassParametersRefs.kgateway Helm value instead of attaching the GatewayParameters to each Gateway individually.
Get the current Helm values for your kgateway installation.
helm get values kgateway -n kgateway-system -o yaml > values.yamlConfigure the
kgatewayGatewayClass with the GatewayParameters resource that you created earlier. Add the following to yourvalues.yamlfile.gatewayClassParametersRefs: kgateway: name: custom-envoy-image namespace: kgateway-systemUpgrade your kgateway installation with the updated values.
helm upgrade -i -n kgateway-system kgateway \ --version v2.4.7 \ oci://cr.kgateway.dev/kgateway-dev/charts/kgateway \ -f values.yaml
Verify
Check that the proxy pods are running the custom image.
kubectl get pods -n kgateway-system -l gateway.networking.k8s.io/gateway-name=my-gateway \
-o jsonpath='{.items[0].spec.containers[0].image}'Example output:
registry.example.com/myorg/envoy-wrapper:v2.3.0-customCleanup
You can remove the resources that you created in this guide.kubectl delete gateway my-gateway -n kgateway-system
kubectl delete GatewayParameters custom-envoy-image -n kgateway-system