The OpenShift Serverless Logic Operator links workflows with the eventing system using Knative Eventing, SinkBindings, and triggers. These objects are created automatically by the OpenShift Serverless Logic Operator and simplify the production and consumption of workflow events.
The following example shows the Knative Eventing objects created for an example-workflow
workflow configured with a platform-scoped eventing system:
apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
name: sonataflow-platform-example
namespace: example-namespace
spec:
eventing:
broker:
ref:
name: example-broker (1)
apiVersion: eventing.knative.dev/v1
kind: Broker
services:
dataIndex: (2)
enabled: true
jobService: (3)
enabled: true
...
1 |
The example-broker object is used by the Data Index, Jobs Service, and the example-workflow workflow. |
2 |
The Data Index is deployed with ephemeral configurations. |
3 |
The Jobs Service is deployed with ephemeral configurations. |
The example-broker
object is a Kafka class Broker, and its configuration is defined in the kafka-broker-config
config map.
The following example displays how to configure a Kafka Knative Broker for use with the SonataFlowPlatform:
apiVersion: eventing.knative.dev/v1
kind: Broker
metadata:
annotations:
eventing.knative.dev/broker.class: Kafka (1)
name: example-broker
namespace: example-namespace
spec:
config:
apiVersion: v1
kind: ConfigMap
name: kafka-broker-config
namespace: knative-eventing
1 |
The Kafka class is used to create the example-broker object. |
The following example displays how the example-workflow
is automatically linked to the example-broker
in the example-namespace
for event production and consumption:
apiVersion: sonataflow.org/v1alpha08
kind: SonataFlow
metadata:
name: example-workflow
namespace: example-namespace
annotations:
sonataflow.org/description: Example Workflow
sonataflow.org/version: 0.0.1
sonataflow.org/profile: preview
spec:
flow:
start: ExampleStartState
events:
- name: outEvent1
source: ''
kind: produced
type: out-event-type1 (1)
- name: inEvent1
source: ''
kind: consumed
type: in-event-type1 (2)
- name: inEvent2
source: ''
kind: consumed
type: in-event-type2 (3)
states:
- name: ExampleStartState
...
1 |
The example-workflow outgoing events are produced by using the SinkBinding named example-workflow-sb . |
2 |
Events of type in-event-type1 are consumed by using the example-workflow-inevent1-b40c067c-595b-4913-81a4-c8efa980bc11 trigger. |
3 |
Events of type in-event-type2 are consumed by using the example-workflow-inevent2-b40c067c-595b-4913-81a4-c8efa980bc11 trigger. |
You can list the automatically created SinkBinding
named example-workflow-sb
by using the following command:
$ oc get sinkbindings -n example-namespace
Example output
NAME TYPE RESOURCE SINK READY
example-workflow-sb SinkBinding sinkbindings.sources.knative.dev broker:example-broker True
You can use the following command to list the automatically created triggers for event consumption:
$ oc get triggers -n <example-namespace>
Example output
NAME BROKER SINK AGE CONDITIONS READY REASON
example-workflow-inevent1-b40c067c-595b-4913-81a4-c8efa980bc11 example-broker service:example-workflow 16m 7 OK / 7 True
example-workflow-inevent2-b40c067c-595b-4913-81a4-c8efa980bc11 example-broker service:example-workflow 16m 7 OK / 7 True