Knative: Operator’s Handbook

Reading external events

External events (eg. AWS SQS, Kafka, GCP Pub/Sub) are read by into Knative cluster using the appropriate Source, converted into CloudEvents and then passed to components such as Broker and Service depending on the delivery method.

For example, to read Google Cloud Pub/Sub messages, you need to define a CloudPubSubSource from Knative-GCP project:

apiVersion: events.cloud.google.com/v1alpha1
kind: CloudPubSubSource
metadata:
  name: cloudpubsubsource-test
spec:
  topic: testing
  sink:
    ref:
      apiVersion: eventing.knative.dev/v1alpha1
      kind: Broker
      name: default

This reads into Pub/Sub mesages from testing topic in GCP, converted into CloudEvents and passed to the Broker in the default namespace.

Then, you can create a Trigger to register an interest to those messages for a Service:

apiVersion: eventing.knative.dev/v1alpha1
kind: Trigger
metadata:
  name: trigger-event-display-pubsub
spec:
  subscriber:
    ref:
      apiVersion: v1
      kind: Service
      name: event-display