You can collect Object Storage Service (OSS) events from MnsOss event sources and manage the events accordingly. This is suitable for scenarios where facial recognition is required. This topic describes how to use Knative to manage MnsOss event sources.
Prerequisites
- Knative Serving and Knative Eventing are installed. For more information, see Deploy Knative.
- An OSS bucket is created in the OSS console. For more information, see Create buckets.
- Message Service (MNS) is activated. For more information, see Activate MNS and authorize RAM users to access MNS.
Step 1: Deploy MnsOss
- Log on to the ACK console.
- In the left-side navigation pane of the ACK console, click Clusters.
- On the Clusters page, find the cluster that you want to manage and click the name of the cluster or click Details in the Actions column. The details page of the cluster appears.
- On the details page of the cluster, choose .
- On the Components tab, find MnsOss and click Deploy in the Actions column.
- In the Deploy MnsOss message, click Confirm.
Step 2: Configure OSS event notification settings
Step 3: Create an MNS token
Step 4: Create a service account and a service broker
Step 5: Create an MnsOss event source
To receive MnsOss events, you must create an MnsOss event source.
Step 6: Create a Knative Service
Create a Knative Service to verify whether the created MnsOss event source works as normal. A Knative Service named event-display is created in this example.
Step 7: Create a trigger
Create a trigger to subscribe to OSS events.
Result
When you upload files to the OSS bucket, notifications are sent to pods.
2020/12/16 13:04:19 receive cloudevents.Event:
{"events": [{
"eventName": "ObjectCreated:PostObject",
"eventSource": "acs:oss",
"eventTime": "2019-06-18T06:44:16.000Z",
"eventVersion": "1.0",
"oss": {
"bucket": {
"arn": "acs:oss:cn-beijing:1041208914252405:testjian",
"name": "testjian",
"ownerIdentity": "1041208914252405",
"virtualBucket": ""},
"object": {
"deltaSize": 0,
"eTag": "137138904F2E18D307D04EB38EA44CDA",
"key": "timg.jpg",
"size": 12990},
"ossSchemaVersion": "1.0",
"ruleId": "demo-i****"},
"region": "cn-beijing",
"requestParameters": {"sourceIPAddress": "42.120.7*.***"},
"responseElements": {"requestId": "5D08884070BC12B192C6****"},
"userIdentity": {"principalId": "104120891425****"}}]}