Skip to content

Example: Kafka event sink

Apply separately

config/samples/kollect_v1alpha1_kollecteventsink_kafka.yaml is not in the default kustomization. Apply it explicitly after a Kafka broker is reachable from the operator namespace.

config/samples/kollect_v1alpha1_kollecteventsink_kafka.yaml — not in default kustomization.

Event + state pairing

Pair Kafka with Postgres via databaseSinkRefs and eventSinkRefs when portals need queryable state and downstream systems need change notifications.

Sample manifest

apiVersion: kollect.dev/v1alpha1
kind: KollectEventSink
metadata:
  name: kafka-inventory-demo
  namespace: default
spec:
  type: kafka
  connectionTest: false
  kafka:
    brokers:
      - kafka.kollect-system.svc:9092
    topic: inventory.changes
Field Purpose
spec.kafka.brokers Broker list (host:port); falls back to spec.endpoint
spec.kafka.topic Topic for aggregated export envelopes (required)
spec.secretRef Optional SASL credentials (username/password keys)
spec.cluster Cluster label embedded in each event envelope

Event emitter role (ADR-0401).

Message contract

Each export publishes one JSON envelope per inventory snapshot — same shape as NATS (ADR-0405):

{
  "schemaVersion": "kollect.dev/v1alpha1",
  "timestamp": "2026-01-15T12:00:00Z",
  "cluster": "prod-west",
  "namespace": "team-a",
  "payload": [/* canonical Item rows */]
}

Delivery is at-least-once. Consumers should key deduplication on {cluster, namespace, timestamp, payload checksum}.

Walkthrough

  1. Ensure a Kafka broker is reachable from the operator (in-cluster Service or external endpoint).
  2. Create a Secret when SASL is required:
apiVersion: v1
kind: Secret
metadata:
  name: kafka-credentials
  namespace: default
stringData:
  username: "<kafka-user>"
  password: "<kafka-password>"
  1. Apply the KollectEventSink sample, then reference it from a KollectInventory:
spec:
  eventSinkRefs:
    - kafka-inventory-demo
  1. Consume with kcat (or your preferred client):
kcat -b kafka.kollect-system.svc:9092 -t inventory.changes -C -o beginning -e

NATS alternative: NATS event sink · config/samples/kollect_v1alpha1_kollecteventsink_nats.yaml.

See also