All Products
Search
Document Center

Container Service for Kubernetes:Use EventBridge for event-driven applications in Knative

Last Updated:Mar 26, 2026

Use EventBridge as the event broker in a Knative Eventing setup to drive on-demand workloads in Container Service for Kubernetes (ACK). When an event arrives — for example, an object upload to Object Storage Service (OSS) — EventBridge routes it through the default event bus to a Trigger. The Trigger filters by event source and type, then forwards matching events to a Knative Service for processing.

Event flow: OSS upload → EventBridge → eventbridge-default-broker → Trigger (filtered by source + type) → Knative Service pod.

You can connect Object Storage Service (OSS) to EventBridge as an event source. For more information, see OSS events.
Architecture diagram showing how OSS events flow through EventBridge and a Knative Trigger to a Knative Service

Prerequisites

Before you begin, make sure you have:

For an overview of EventBridge concepts, see What is EventBridge?

Step 1: Deploy the Eventing and EventBridge components

Deploy Eventing first, then EventBridge. Eventing provides the broker and trigger infrastructure; EventBridge connects Alibaba Cloud service event sources to that infrastructure.

  1. Log on to the ACK console. In the left-side navigation pane, click ACK consoleACK consoleClusters.

  2. On the Clusters page, click the name of the cluster you want to manage. In the left-side navigation pane, choose Applications > Knative.

  3. On the Components tab, deploy the two components in order: Both components show Deployed in the Status column when ready.

    1. Find Eventing and click Deploy in the Actions column.

    2. After Eventing shows Deployed in the Status column, find EventBridge and click Deploy in the Actions column. In the dialog box, enter your AccessKey ID and AccessKey secret, then click OK. To get your AccessKey pair, see Create an AccessKey. > Note: To protect your RAM user account, bind a multi-factor authentication (MFA) device for secondary verification on console logon and sensitive operations. For details, see Bind an MFA device to a RAM user.

Step 2: Create a Knative Service

Create a Knative Service to act as the event consumer. The following steps use a service named event-display, which records all received events. This makes it useful for verifying end-to-end event delivery.

Use the ACK console

  1. Log on to the ACK console and navigate to your cluster's Applications > Knative page.

  2. Click the Services tab, then click Create from Template.

  3. Paste the following YAML and submit.

    apiVersion: serving.knative.dev/v1
    kind: Service
    metadata:
      name: event-display
      namespace: default
    spec:
      template:
        spec:
          containers:
          - image: registry.cn-hangzhou.aliyuncs.com/knative-sample/event-display:20230207194118_3874dbd

    On the Services tab, the service is ready when the Status column shows Created.

Use kubectl

  1. Create a file named event-display.yaml with the following content:

    apiVersion: serving.knative.dev/v1
    kind: Service
    metadata:
      name: event-display
      namespace: default
    spec:
      template:
        spec:
          containers:
          - image: registry.cn-hangzhou.aliyuncs.com/knative-sample/event-display:20230207194118_3874dbd
  2. Apply the manifest:

    kubectl apply -f event-display.yaml
  3. Verify the service is ready:

    kubectl get ksvc

    The service is ready when READY is True:

    NAME            URL                                        LATESTCREATED         LATESTREADY           READY   REASON
    event-display   http://event-display.default.example.com   event-display-00001   event-display-00001   True

    If READY is False, wait a few seconds and run the command again.

Step 3: Create a Trigger

A Trigger tells the broker which events to forward and where to send them. The broker field connects the Trigger to an event bus. The filter fields determine which events pass through — only events matching all specified attributes reach the subscriber. The subscriber field points to the Knative Service that receives matching events.

Use the ACK console

  1. On the Knative page, click the Services tab and then click the name of the Knative Service. On the service detail page, click the Trigger tab.

  2. Click Create Trigger and configure the parameters on the Configure page. After the Trigger is created, it appears on the Triggers tab.

    ParameterDescriptionExample
    NameA name for the Triggermy-service-trigger
    BrokerSelect EventBridge or OtherEventBridge
    Event sourceThe event source to filter on. Multiple event sources are supported.OSS
    Event typeThe event type to filter on. Multiple types are supported. Events that do not match any specified type are dropped.oss:ActionTrail:ConsoleOperation

    Triggers tab showing a newly created trigger named my-service-trigger

Use kubectl

  1. Create a file named my-service-trigger.yaml with the following content:

    FieldValueEffect
    brokereventbridge-default-brokerConnects the Trigger to the default EventBridge event bus. Events not on this bus are ignored.
    sourceacs.ossOnly events from OSS are forwarded. Events from other sources are dropped.
    typeoss:ActionTrail:ConsoleOperationOnly events of this type are forwarded. Separate multiple types with commas (,).
    subscriberService name and namespaceThe Knative Service that receives matching events.
    apiVersion: eventing.knative.dev/v1
    kind: Trigger
    metadata:
      name: my-service-trigger
    spec:
      broker: eventbridge-default-broker
      filter:
        attributes:
          source: acs.oss
          type: 'oss:ActionTrail:ConsoleOperation'
      subscriber:
        ref:
          apiVersion: serving.knative.dev/v1
          kind: Service
          name: helloworld-go
          namespace: default

    Key fields and their effect on event routing:

  2. Apply the manifest:

    kubectl apply -f my-service-trigger.yaml
  3. Verify the Trigger is ready:

    kubectl get triggers

    The Trigger is ready when READY is True:

    NAME                         BROKER                       SUBSCRIBER_URI                                   AGE   READY   REASON
    my-service-trigger           eventbridge-default-broker   http://helloworld-go.default.svc.cluster.local   42h   True

    If READY is False, wait a few seconds and run the command again.

Step 4: Verify end-to-end event delivery

Trigger an OSS event and confirm that EventBridge delivers it to the Knative Service.

  1. Upload an object to your OSS bucket:

    Important

    The OSS bucket and EventBridge must be in the same region.

    ossutil cp <file-name> oss://<bucket-name>

    After the upload completes, EventBridge detects the event and routes it through the Trigger to the Knative Service.

  2. Check the event trace in the EventBridge console:

    1. Log on to the EventBridge console. In the left-side navigation pane, click Event Buses.

    2. On the Event Buses page, find the default event bus and click Event Tracking in the Actions column.

    3. On the Query By Time Range tab, set a Time Range and click Query.

    4. Set Event Source to OSS and Event Type to Put Object, then click Event Trace in the Operations column to confirm the event was delivered. image.png

  3. Confirm the Knative Service consumed the event:

    1. Check that a pod is running:

      kubectl get pod

      Expected output:

      NAME                                              READY   STATUS    RESTARTS   AGE
      event-display-00001-deployment-56cc79****-z2vhv   2/2     Running   0          7s

      If no pod appears, wait a few seconds and run the command again. The Knative Service scales to zero when idle and starts a new pod when it receives an event.

    2. View the event log:

      kubectl logs event-display-00001-deployment-56cc79****-z2vhv user-container

      Expected output:

      {"data":{"eventVersion":"1.0","responseElements":{"requestId":"63E21F5FEE852133319101AD"},"eventSource":"acs:oss","eventTime":"2023-02-07T09:52:31.000Z","requestParameters":{"sourceIPAddress":"XX.XXX.XX.XXX"},"eventName":"ObjectCreated:PutObject","userIdentity":{"principalId":"1118324452360952"},"region":"cn-hangzhou","oss":{"bucket":{"name":"knative","arn":"acs:oss:cn-hangzhou:1581204543170042:knative","virtualBucket":"","ownerIdentity":"1581204543170042"},"ossSchemaVersion":"1.0","object":{"size":225496,"objectMeta":{"mimeType":"application/octet-stream"},"deltaSize":0,"eTag":"B350C082843DAC7E9E634193437EBA30","key":"demo.data"}}}}}

      The log shows \"eventSource\":\"acs:oss\" and \"eventName\":\"ObjectCreated:PutObject\", confirming that EventBridge successfully triggered the Knative Service to consume the OSS upload event.

What's next

To set up event-driven workflows with other event sources, see Use GitHub events in Knative.