All Products
Search
Document Center

Container Service for Kubernetes:Trigger Knative services with EventBridge

Last Updated:Jun 25, 2026

Knative Eventing provides a complete event model for integrating external event sources. Deploy Knative Eventing in your ACK cluster and create triggers to route EventBridge events to Knative Services for event-driven workloads.EventBridge events to Knative Services for event-driven workloads.

Prerequisites

How it works

EventBridge receives events from various sources. You configure an event bus, rules, and targets to filter, transform, and route events to Knative Services for on-demand consumption. The following figure shows the architecture.

Note

You can connect OSS to EventBridge as an event source. See OSS events for supported event types.

image

Step 1: Deploy the Eventing and EventBridge components

Knative uses EventBridge for event-driven capabilities, supporting Alibaba Cloud event sources and event forwarding.

  1. Log on to the ACK console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the name of your cluster. In the left navigation pane, click Applications > Knative.

  3. On the Add-ons tab, deploy the Eventing and EventBridge components.

    1. On the Add-ons tab, find the Eventing component and click Deployments in the Actions column.

    2. After Eventing is deployed, find the EventBridge component and click Deployments in the Actions column. Enter your AccessKey ID and AccessKey secret, then click OK.

      See Create an AccessKey pair.

      Note

      To enhance the security of your RAM user, you can bind an MFA device for secondary authentication during console sign-ins or when you perform sensitive operations. This provides an extra layer of protection beyond a username and password. For more information, see Bind an MFA device for a RAM user.

    If the Status of the components is Deployed, the deployment is successful.

Step 2: Create a Knative Service

Create a Knative Service named event-display that logs received events. You can use the ACK console or kubectl.

Console

  1. Log on to the ACK console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the name of your cluster. In the left navigation pane, click Applications > Knative.

  3. On the Services tab, click Create from Template.

    Example:

    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, a Status of Success confirms the Service is created.

Kubectl

  1. Save the following as event-display.yaml and apply it:

    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
    kubectl apply -f event-display.yaml
  2. Check the Knative Service status:

    kubectl get ksvc

    Expected output:

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

Step 3: Create a trigger

Console

  1. On the Knative page, click the Services tab. Click the target Service, then click the Trigger tab.

  2. Click Create Trigger. On the Configuration page, set the following parameters:

    Parameter

    Description

    Example

    Name

    The trigger name.

    my-service-trigger

    Broker

    Select EventBridge or Others.

    EventBridge

    Event Source

    Select an event source.

    OSS

    Event Type

    Select an event type.

    oss:ActionTrail:ConsoleOperation

    The trigger appears on the Triggers tab.

Kubectl

  1. Save the following as my-service-trigger.yaml and apply it:

    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: event-display
          namespace: default
    • broker: The eventbridge-default-broker, corresponding to the default event bus (default) in EventBridge.

    • source: The event source.

    • type: The event type. Separate multiple types with a comma (,).

    • subscriber: The target Knative Service.

    kubectl apply -f my-service-trigger.yaml
  2. Check the trigger status:

     kubectl get triggers

    Expected output:

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

Step 4: Verify event consumption

  1. Upload a file to your OSS bucket.

    Note

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

    ossutil cp <file_name> oss://<bucket_name>

    After the upload, EventBridge triggers the Knative Service to consume the event.

  2. View the Event Trace.

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

    2. Find the default event bus and click Event Tracking in the Actions column. On the Query By Time Range tab, set a Time Range and click Search.

    3. Find the event where the Event Source is Object Storage Service and the Event Type is Upload Object. Click Event Trace in the Actions column.

      A delivery status of Succeeded with response [200] confirms EventBridge delivered the event.

      The Event Trace page shows the full delivery status.

  3. Verify that the Knative Service consumed the event.

    1. Check for the pod created to consume the event:

      kubectl get pod

      Expected output:

      NAME                                              READY   STATUS    RESTARTS         AGE
      event-display-00001-deployment-56cc79****-z2vhv   2/2     Running   0                7s
    2. View the logs to confirm the Knative Service recorded the event:

      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 output confirms the Knative Service consumed the OSS file upload event.