Policies control how Kafka protocol traffic is modified between the client and the backend cluster.
There are two main types of policies:
Virtual cluster policies: Transformation and validation policies applied to Kafka messages.
Virtual cluster policies break down further into cluster, consume, and produce policies.
Listener policies: Routing policies that pass traffic to the virtual cluster.
Policies execute in chains. The order in which Kong Event Gateway applies policies to modify messages depends on the policy type, and whether the message is a request or response.
flowchart LR
A[Kafka
client]
B[Listener
(TCP socket)
+ listener policies]
C@{ shape: processes, label: "Virtual clusters
+ consume, produce,
and cluster policies"}
D[Backend
cluster]
E[Kafka
cluster]
A --> B
subgraph id1 [Event Gateway]
B --> C
C --> D
end
D --> E
style B stroke:#86e2cc
style C stroke:#86e2cc
style id1 rx:7,ry:7
Virtual cluster policies are applied to Kafka traffic via virtual clusters. They let you modify headers, encrypt or decrypt records, validate schemas, and more.
Kong Event Gateway has a few built-in virtual cluster policies, all of which have their own specific configurations and examples.
See all Event Gateway policies for their individual configurations.
Here’s an example configuration for the Modify Headers consume policy:
Listener policies are applied to layer 4 TCP traffic on listeners,
for example to enforce TLS, select a certificate for the TLS connection, or to route to a specific virtual cluster.
Kong Event Gateway has a few built-in listener policies, all of which have their own specific configurations and examples.
See all Event Gateway policies for their individual configurations.
Here’s an example configuration for the Forward to Virtual Cluster policy:
Policies have a condition field that determines whether the policy executes or not.
By writing conditions using expressions, you can access dynamic configuration from the execution context.
For example, you can create a condition that selects all topics that end with the suffix my_suffix: