Port Forwarding (K8s)
This page provides documentation on how to solve a common problem with WarpStream: connecting to Agents deployed in K8s by port-forwarding.
If you're running WarpStream in Kubernetes, you may have noticed that port-forwarding to the Agents does not work immediately. For example, if you run the follow comand in one terminal:
and then run the following command in another terminal, you'll get an error:
You'll get an error like this:
The reason for this is that your initial client connection will reach the Agent successfully, but then the client will perform a Metadata request for service discovery and the WarpStream control plane will instruct the client to connect to other Agents using their internal IP addresses (the ones reachable in K8s, but not from your laptop). You can read more about WarpStream service discovery in this documentation for more details.
To work around this issue, WarpStream has a feature to instruct the service discovery system to report all the other Agents hostnames as localhost
so that when your client performs service discovery via the Metadata request and gets redirected, it will just re-use the existing port-forward. This works because all the WarpStream Agents are stateless, none are special, and any Agent can successfully handle any Kafka protocol request.
To enable this feature from your laptop, simply add the following string to your Kafka client ID: ws_host_override=localhost
. Using the WarpStream CLI, that would look like this:
This time it should just work, enjoy your local development experience!
Last updated