Search code examples
apache-kafkaknative-eventing

What is the proper way for a service to send events to multiple knative brokers?


I have a service that I want to post events to multiple brokers, [one in a different namespace]. The issue is that even though I have set up multiple Sinkbinding, K_SINK is being injected in the service pod with only one broker endpoint instead of two. Am I missing something or is there better way of posting events to multiple brokers, besides hardcoding the Knative Broker Ingress URL and dynamically create the full URL in code based upon the broker name and namespace?

Ultimately, I just want to post to different Kafka topics.


Solution

  • Having multiple K_SINKs in a SinkBinding is as of today not possible. So you could create a feature request for this.

    What you could do in the meantime is to point your sink of your SinkBinding to Broker. And then have multiple Triggers for this Broker, sending the events to a Sink (or if you only want differnt topics, a KafkaSink):

                          ┌──► Trigger1 ───► Sink1
                          │
    Service ────► Broker ─├──► Trigger2 ───► Sink2
                          │
                          └──► Trigger3 ───► Sink3
    

    In your SinkBinding, your sink would be the Broker and the subject the Service, which then gets the Brokers address in the K_SINK.