Knative — Curling the Knative Broker Directly

↳ 📅 8/25/2022 ✍ guide, software, programming, knative

Want to read this on Substack? Now you can!

When using Knative, a developer may want to sometimes directly curl the broker without configuring a source, as Knative traditionally requires. This guide explains how to work around that for a faster development cycle.

  1. From the Knative documentation, the suggested interacted path is that your curl hits a configured Knative Source, which is sent to a Broker, which then sends (in a one-to-many relationship) to Sinks (consumers). While this is great for production-ready scenarios, a developer may not want to configure all of these CRDs during a simple development test.
    1. Ensure you have a working Knative installation (verified on Knative 1.8)
    2. Ensure you have a working Knative Broker configured
  2. Port forward to the Broker's ingress: kubectl port-forward -n knative-eventing svc/broker-ingress 8080:80
  3. curl to localhost:
    
    curl -w'\n' http://localhost:8080/demo/default \
        -H "ce-id: 0001" \
        -H "ce-specversion: 1.0" \
        -H "ce-type: hello" \
        -H "ce-source: somewhere" \
        -H "Content-Type: application/json" \
        -X POST -i
                        

Written as of Knative 1.8 -- hope this helps.
- bryan

Back to Blog Back to Home