Skip to content

Knative

Charles d'Avernas edited this page Nov 30, 2026 · 1 revision

Cloud Streams works alongside Knative Eventing: Knative sources and triggers deliver to its gateways, its subscriptions deliver to Knative's addressable objects, and its subscribers may reply with cloud events, as Knative subscribers do. Nothing of Knative is required to run Cloud Streams. Delivering by reference needs the Kubernetes mode (see Kubernetes-native mode).

Knative to Cloud Streams

A gateway's ingestion endpoint is a Knative sink. Refer to its service, with the path of the endpoint, which Knative resolves relative to the service:

apiVersion: sources.knative.dev/v1
kind: PingSource
metadata:
  name: pings
  namespace: tenant-a
spec:
  schedule: "* * * * *"
  data: '{"message":"ping"}'
  sink:
    ref: { apiVersion: v1, kind: Service, name: orders-gateway }   # the service of the gateway 'orders'
    uri: /api/events/pub
  • Any source or trigger: the same sink, or subscriber for a trigger, works for every Knative source, e.g. ApiServerSource, KafkaSource or SinkBinding, and for triggers and channel subscriptions.
  • Address: gateways report where they receive cloud events in their status.address.url, as Knative's Addressable duck type does, e.g. http://orders-gateway.tenant-a.svc.cluster.local/api/events/pub. Knative can't refer to a gateway as kind: Gateway though: it guesses the resource of a kind from its name, as gatewaies. Refer to its service, as above, or to that URL with uri.
  • Content modes: Knative delivers in the binary content mode, which gateways accept (see Ingestion).

Cloud Streams to Knative

A subscriber, a reply destination or a dead-letter destination may be a ref to an addressable Kubernetes object of the subscription's namespace, in place of an endpoint or a sink:

apiVersion: cloud-streams.io/v1
kind: Subscription
metadata:
  name: billing
  namespace: tenant-a
spec:
  filter: { type: sql, sql: "type LIKE 'order.%'" }
  subscriber:
    ref: { apiVersion: serving.knative.dev/v1, kind: Service, name: billing }
  deadLetter:
    ref: { apiVersion: eventing.knative.dev/v1, kind: Broker, name: dead-letters }
  • Addressable objects: Knative Services, Brokers, Channels, Sequences and Parallels, any object that reports its address in its status.address.url, gateways, and Kubernetes services (apiVersion: v1, kind: Service), which are delivered to at http://{name}.{namespace}.svc.{clusterDomain}/.
  • Resolution: brokers read the object, and cache its address for 5 seconds. An object that doesn't exist, or reports no address yet, fails the delivery, which is retried as any other, and the subscription's subscriber state tells why, e.g. Broker.eventing.knative.dev/v1 'default' of the Kubernetes namespace 'tenant-a' is not addressable, or not yet.
  • Rights: brokers may read the objects of their namespace that Knative labels addressable. The chart's <release>-broker ClusterRole aggregates the ClusterRoles labelled duck.knative.dev/addressable: "true", which Knative ships for its own kinds, and any you add for other kinds. The API, which redelivers dead letters, is bound to <release>-addressable-resolver, which aggregates the same.
  • Cluster domain: resources.kubernetes.clusterDomain, cluster.local by default, is the domain the addresses of services and gateways end with.
  • Redis mode: references can't be resolved there. A subscription that uses one keeps failing its deliveries, until it's changed.

Replies

A Knative subscriber may respond to a cloud event with another one, which Knative publishes to the broker. A subscriber's reply does the same, to any destination:

spec:
  subscriber:
    ref: { apiVersion: serving.knative.dev/v1, kind: Service, name: billing }
    reply:
      ref: { apiVersion: cloud-streams.io/v1, kind: Gateway, name: orders }   # or an endpoint, or a sink
  • What's a reply: a response, with a success status code, that carries a structured or a binary cloud event, or a batch of them. Other responses, e.g. empty or plain text, aren't replies. Replies to a gateway go through its validation, authorization and deduplication, as any published cloud event.
  • Failures: a reply that can't be sent fails the delivery it answers, which is retried, whatever the subscriber's status code: the subscriber then receives the cloud event again. So does an invalid reply, e.g. a structured cloud event without a type, or one larger than 4 MiB.
  • Loops: a subscription whose filter selects the cloud events its subscriber replies with delivers them to it again. Filter them out, e.g. by type.
  • Scope: replies are only read from HTTP responses: a subscriber delivered to over another transport, e.g. Kafka, may not have a reply. They're read from batched and parallel deliveries too, and from redeliveries. Without a reply, responses are ignored, as before.

Dashboard and kubectl

The subscription form delivers to an endpoint, a sink or a Kubernetes object, and sends replies elsewhere. kubectl cloud-streams describe shows references as kubectl names objects, e.g. service.serving.knative.dev/billing, and a subscription's replies.

Clone this wiki locally