Configure NAT for Kafka
To reach a Kafka cluster from outside the VPC over a public IP, you need three things in place: an open port, DNAT rules for every node, and the cluster's public_endpoint parameter pointing at that public IP.
public_endpoint is a Static parameter, so saving it restarts the cluster and briefly interrupts producers and consumers. Do this work during off-peak hours.
Open the required port
Configure the Security Group to allow inbound traffic on port 9093 for every Kafka node. See Connect to database with Floating IP for how to create and apply one.
Configure DNAT rules
Map one public port per node, all pointing at internal port 9093. Substitute your own public address for IP_PUBLIC and your node addresses for IP_NODE_n.
For a single-node cluster:
| Public | Destination |
|---|---|
IP_PUBLIC:9092 | IP_NODE_1:9093 |
For a three-node cluster:
| Public | Destination |
|---|---|
IP_PUBLIC:9092 | IP_NODE_1:9093 |
IP_PUBLIC:9093 | IP_NODE_2:9093 |
IP_PUBLIC:9094 | IP_NODE_3:9093 |
Each node needs its own public port. Kafka clients are redirected to individual brokers after the initial connection, so a single mapping leaves two thirds of a three-node cluster unreachable.
Set the public endpoint
- Open the Configure Params page for the Kafka cluster. See Configure parameters.
- Select parameter type Static.
- Set
public_endpointto yourIP_PUBLICvalue. - Click Save.
The cluster restarts to apply the change. Once it returns to Running, external clients can connect through the public IP.