Questo contenuto non è disponibile nella lingua selezionata.

Chapter 5. Supporting services


5.1. Job service

The Job service schedules and executes tasks in a cloud environment. Independent services implement these tasks, which can be initiated through any of the supported interaction modes, including HTTP calls or Knative Events delivery.

In OpenShift Serverless Logic, the Job service is responsible for controlling the execution of the time-triggered actions. Therefore, all the time-based states that you can use in a workflow, are handled by the interaction between the workflow and the Job service.

For example, every time the workflow execution reaches a state with a configured timeout, a corresponding job is created in the Job service, and when the timeout is met, an HTTP callback is executed to notify the workflow.

The main goal of the Job service is to manage active jobs, such as scheduled jobs that need to be executed. When a job reaches its final state, the Job service removes it. To retain jobs information in a permanent repository, the Job service produces status change events that can be recorded by an external service, such as the Data Index Service.

Note

You do not need to manually install or configure the Job service if you are using the OpenShift Serverless Operator to deploy workflows. The Operator handles these tasks automatically and manages all necessary configurations for each workflow to connect with it.

5.1.1. Job service leader election process

The Job service operates as a singleton service, meaning only one active instance can schedule and execute jobs.

To prevent conflicts when the service is deployed in the cloud, where multiple instances might be running, the Job service supports a leader election process. Only the instance that is elected as the leader manages external communication to receive and schedule jobs.

Non-leader instances remain inactive in a standby state but continue attempting to become the leader through the election process. When a new instance starts, it does not immediately assume leadership. Instead, it enters the leader election process to determine if it can take over the leader role.

If the current leader becomes unresponsive or if it is shut down, another running instance takes over as the leader.

Note

This leader election mechanism uses the underlying persistence backend, which is currently supported only in the PostgreSQL implementation.

5.2. Data Index service

The Data Index service is a dedicated supporting service that stores the data related to the workflow instances and their associated jobs. This service provides a GraphQL endpoint allowing users to query that data.

5.2.1. Data Index service overview

The Data Index service processes data received through events that originate from workflows or directly from the Job service. It consumes CloudEvents messages by using Apache Kafka or Knative Eventing and stores the processed data in a database.

The service indexes workflow execution data and provides access to it through a GraphQL API. This capability enables you to search, monitor, and analyze workflow execution details. The Data Index service plays a central role in providing insights and management capabilities in OpenShift Serverless Logic.

Key features of the Data Index service
  • Flexible data structure for handling workflow event data
  • Distributed and cloud-ready architecture
  • Message-based communication using Apache Kafka, Knative Eventing, and CloudEvents
  • GraphQL API for querying indexed workflow data
Note

When you use the OpenShift Serverless Operator to deploy workflows, the Operator automatically manages the Data Index service and configures workflows to connect to it. You do not need to install or configure the service manually.

5.2.2. GraphQL queries for workflow instances and jobs

To retrieve data about workflow instances and jobs, you can use GraphQL queries.

5.2.2.1. Retrieve data from workflow instances

You can use the following GraphQL query to retrieve workflow instance details, including node-level data such as input and output arguments.

{
  ProcessInstances {
    id
    processId
    state
    parentProcessInstanceId
    rootProcessId
    rootProcessInstanceId
    variables
    nodes {
      id
      name
      type
      inputArgs
      outputArgs
    }
  }
}

The inputArgs and outputArgs fields provide additional details about the data passed to and produced by each workflow node. These fields help you understand how data flows between nodes during workflow execution.

Note

The inputArgs and outputArgs fields are optional. These fields are enabled by default for Serverless Workflow and capture input and output data for workflow functions.

You can disable argument recording by using the following configuration properties:

  • To disable argument recording for all functions:

    kogito.sw.functions.recordArgs=false
  • To disable argument recording for a specific function:

    kogito.sw.functions.<function_name>.recordArgs=false

You can configure these properties in the application.properties file or by using Kubernetes configuration.

5.2.2.2. Retrieve data from jobs

You can retrieve data from a specific job instance by using the following query example:

{
  Jobs {
    id
    status
    priority
    processId
    processInstanceId
    executionCounter
  }
}

5.2.2.3. Filter query results by using the where parameter

You can filter query results by using the where parameter, allowing multiple combinations based on workflow attributes.

The following example displays a query to filter by state:

{
  ProcessInstances(where: {state: {equal: ACTIVE}}) {
    id
    processId
    processName
    start
    state
    variables
  }
}

The following example displays a query to filter by ID:

{
  ProcessInstances(where: {id: {equal: "d43a56b6-fb11-4066-b689-d70386b9a375"}}) {
    id
    processId
    processName
    start
    state
    variables
  }
}​

By default, filters are combined using the AND Operator. You can change this behavior by combining filters with the AND or OR Operators.

The following example displays a query to combine filters with the OR Operator:

{
  ProcessInstances(where: {or: {state: {equal: ACTIVE}, rootProcessId: {isNull: false}}}) {
    id
    processId
    processName
    start
    end
    state
  }
}

The following example displays a query to combine filters with the AND and OR Operators:

{
  ProcessInstances(where: {and: {processId: {equal: "travels"}, or: {state: {equal: ACTIVE}, rootProcessId: {isNull: false}}}}) {
    id
    processId
    processName
    start
    end
    state
  }
}

Depending on the attribute type, you can use the following available Operators:

Expand
Attribute typeAvailable Operators

String array

  • contains: String
  • containsAll: Array of strings
  • containsAny: Array of strings
  • isNull: Boolean (true or false)

String

  • in: Array of strings
  • like: String
  • isNull: Boolean (true or false)
  • equal: String

ID

  • in: Array of strings
  • isNull: Boolean (true or false)
  • equal: String

Boolean

  • isNull: Boolean (true or false)
  • equal: Boolean (true or false)

Numeric

  • in: Array of integers
  • isNull: Boolean
  • equal: Integer
  • greaterThan: Integer
  • greaterThanEqual: Integer
  • lessThan: Integer
  • lessThanEqual: Integer
  • between: Numeric range
  • from: Integer
  • to: Integer

Date

  • isNull: Boolean (true or false)
  • equal: Date time
  • greaterThan: Date time
  • greaterThanEqual: Date time
  • lessThan: Date time
  • lessThanEqual: Date time
  • between: Date range
  • from: Date time
  • to: Date time

5.2.2.4. Sort query results by using the orderBy parameter

You can sort query results based on workflow attributes by using the orderBy parameter. You can also specify the sorting direction in an ascending (ASC) or a descending (DESC) order. Multiple attributes are applied in the order you specified.

The following example displays a query to sort by the start time in an ASC order:

{
  ProcessInstances(where: {state: {equal: ACTIVE}}, orderBy: {start: ASC}) {
    id
    processId
    processName
    start
    end
    state
  }
}

5.2.2.5. Limit the number of results by using the pagination parameter

You can control the number of returned results and specify an offset by using the pagination parameter.

The following example displays a query to limit results to 10, starting from offset 0:

{
  ProcessInstances(where: {state: {equal: ACTIVE}}, orderBy: {start: ASC}, pagination: {limit: 10, offset: 0}) {
    id
    processId
    processName
    start
    end
    state
  }
}

5.3. Managing supporting services

This section provides an overview of the supporting services essential for OpenShift Serverless Logic. It specifically focuses on configuring and deploying the Data Index service and Job Service supporting services using the OpenShift Serverless Logic Operator.

In a typical OpenShift Serverless Logic installation, you must deploy both services to ensure successful workflow execution. The Data Index service allows for efficient data management, while the Job Service ensures reliable job handling.

5.3.1. Supporting services and workflow integration

When you deploy a supporting service in a given namespace, you can choose between an enabled or disabled deployment. An enabled deployment signals the OpenShift Serverless Logic Operator to automatically intercept workflow deployments using the preview or gitops profile within the namespace and configure them to connect with the service.

For example, when the Data Index service is enabled, workflows are automatically configured to send status change events to it. Similarly, enabling the Job Service ensures that a job is created whenever a workflow requires a timeout. The OpenShift Serverless Logic Operator also configures the Job Service to send events to the Data Index service, facilitating seamless integration between the services.

The OpenShift Serverless Logic Operator does not just deploy supporting services, it also manages other necessary configurations to ensure successful workflow execution. All these configurations are handled automatically. You only need to provide the supporting services configuration in the SonataFlowPlatform CR.

Note

Deploying only one of the supporting services or using a disabled deployment are advanced use cases. In a standard installation, you must enable both services to ensure smooth workflow execution.

5.3.2. Supporting services deployment with the SonataFlowPlatform CR

To deploy supporting services, configure the dataIndex and jobService subfields within the spec.services section of the SonataFlowPlatform custom resource (CR). This configuration instructs the OpenShift Serverless Logic Operator to deploy each service when the SonataFlowPlatform CR is applied.

Each configuration of a service is handled independently, allowing you to customize these settings alongside other configurations in the SonataFlowPlatform CR.

See the following scaffold example configuration for deploying supporting services:

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
  name: sonataflow-platform-example
  namespace: example-namespace
spec:
  services:
    dataIndex: 
1

      enabled: true 
2

      # Specific configurations for the Data Index Service
      # might be included here
    jobService: 
3

      enabled: true 
4

      # Specific configurations for the Job Service
      # might be included here
1
Data Index service configuration field.
2
Setting enabled: true deploys the Data Index service. If set to false or omitted, the deployment will be disabled. The default value is false.
3
Job Service configuration field.
4
Setting enabled: true deploys the Job Service. If set to false or omitted, the deployment will be disabled. The default value is false.

5.3.3. Supporting services scope

The SonataFlowPlatform custom resource (CR) enables the deployment of supporting services within a specific namespace. This means all automatically configured supporting services and workflow communications are restricted to the namespace of the deployed platform.

This feature is particularly useful when separate instances of supporting services are required for different sets of workflows. For example, you can deploy an application in isolation with its workflows and supporting services, ensuring they remain independent from other deployments.

5.3.4. Supporting services persistence configurations

The persistence configuration for supporting services in OpenShift Serverless Logic can be either ephemeral or PostgreSQL, depending on needs of your environment. Ephemeral persistence is ideal for development and testing, while PostgreSQL persistence is recommended for production environments.

5.3.4.1. Ephemeral persistence configuration

The ephemeral persistence uses an embedded PostgreSQL database that is dedicated to each service. The OpenShift Serverless Logic Operator recreates this database with every service restart, making it suitable only for development and testing purposes. You do not need any additional configuration other than the following SonataFlowPlatform CR:

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
  name: sonataflow-platform-example
  namespace: example-namespace
spec:
  services:
    dataIndex:
      enabled: true
      # Specific configurations for the Data Index Service
      # might be included here
    jobService:
      enabled: true
      # Specific configurations for the Job Service
      # might be included here

5.3.4.2. Database migration configuration

Database migration refers to either initializing a given Data Index or Jobs Service database to its respective schema, or applying data or schema updates when new versions are released. You must configure the database migration strategy individually for each supporting service by using the dataIndex.persistence.dbMigrationStrategy and jobService.persistence.dbMigrationStrategy optional fields. If you do not configure a migration strategy, the system uses service as the default value.

Note

Database migration is supported only when using the PostgreSQL persistence configuration.

You can configure any of the following database migration strategies:

5.3.4.2.1. Job-based database migration strategy

When you configure the job-based strategy, the OpenShift Serverless Logic Operator uses a dedicated Kubernetes Job to manage the entire migration process. This Job runs before the supporting services deployment, ensuring that a service starts only if the corresponding migration completes successfully. You typically use this strategy in production environments.

5.3.4.2.2. Service-based database migration strategy

When you configure the service-based strategy, the database migration is managed directly by each supporting service. The migration is executed as part of the service startup sequence. In worst-case scenarios, a service might start with failures if the migration is unsuccessful. Service-based database migration is the default strategy when you do not specify any configuration.

5.3.4.2.3. None migration strategy

When you configure the none strategy, neither the Operator nor the service attempts to perform the migration. You typically use this strategy in environments where a database administrator (DBA) manually executes all database migrations.

5.3.4.3. PostgreSQL persistence configuration

For PostgreSQL persistence, you must set up a PostgreSQL server instance on your cluster. The administration of this instance remains independent of the OpenShift Serverless Logic Operator control. To connect a supporting service with the PostgreSQL server, you must configure the appropriate database connection parameters.

You can configure PostgreSQL persistence in the SonataFlowPlatform CR by using the following example:

Example of PostgreSQL persistence configuration

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
  name: sonataflow-platform-example
  namespace: example-namespace
spec:
  services:
    dataIndex:
      enabled: true
      persistence:
        dbMigrationStrategy: job 
1

        postgresql:
          serviceRef:
            name: postgres-example 
2

            namespace: postgres-example-namespace 
3

            databaseName: example-database 
4

            databaseSchema: data-index-schema 
5

            port: 1234 
6

          secretRef:
            name: postgres-secrets-example 
7

            userKey: POSTGRESQL_USER 
8

            passwordKey: POSTGRESQL_PASSWORD 
9

    jobService:
      enabled: true
      persistence:
        dbMigrationStrategy: job
        postgresql:
        # Specific database configuration for the Job Service
        # might be included here.

1
Optional: Database migration strategy to use. Defaults to service.
2
Name of the service to connect with the PostgreSQL database server.
3
Optional: Defines the namespace of the PostgreSQL Service. Defaults to the SonataFlowPlatform namespace.
4
Defines the name of the PostgreSQL database for storing supporting service data.
5
Optional: Specifies the schema for storing supporting service data. Default value is SonataFlowPlatform name, suffixed with -data-index-service or -jobs-service. For example, sonataflow-platform-example-data-index-service.
6
Optional: Port number to connect with the PostgreSQL Service. Default value is 5432.
7
Defines the name of the secret containing the username and password for database access.
8
Defines the name of the key in the secret that contains the username to connect with the database.
9
Defines the name of the key in the secret that contains the password to connect with the database.
Note

You can configure each service’s persistence independently by using the respective persistence field.

Create the secrets to access PostgreSQL by running the following command:

$ oc create secret generic <postgresql_secret_name> \
  --from-literal=POSTGRESQL_USER=<user> \
  --from-literal=POSTGRESQL_PASSWORD=<password> \
  -n <namespace>

5.3.4.4. Common PostgreSQL persistence configuration

The OpenShift Serverless Logic Operator automatically connects supporting services to the common PostgreSQL server configured in the spec.persistence field.

For rules, the following precedence is applicable:

  • If you configure a specific persistence for a supporting service, for example, services.dataIndex.persistence, it uses that configuration.
  • If you do not configure persistence for a service, the system uses the common persistence configuration from the current platform.
Note

When using a common PostgreSQL configuration, each service schema is automatically set as the SonataFlowPlatform name, suffixed with -data-index-service or -jobs-service, for example, sonataflow-platform-example-data-index-service.

5.3.4.5. Platform-scoped PostgreSQL persistence configuration

You can configure a common PostgreSQL service and database for all supporting services by using the spec.persistence.postgresql field in the SonataFlowPlatform Custom Resource (CR). When this field is configured, the OpenShift Serverless Logic Operator connects the supporting services to the specified database. Any workflows deployed in the same namespace using the preview or gitops profiles, and that do not specify a custom persistence configuration, will also connect to this database.

The following rules apply when configuring platform-scoped persistence:

  • If a supporting service has its own persistence configuration, for example, if services.dataIndex.persistence.postgresql is set, then that configuration takes precedence.
  • If a supporting service does not have a custom persistence configuration, the configuration is inherited from the current platform.
  • If a supporting service requires a specific database migration strategy, configure it by using the dataIndex.persistence.dbMigrationStrategy and jobService.persistence.dbMigrationStrategy fields.

The following SonataFlowPlatform CR fragment shows how to configure platform-scoped PostgreSQL persistence:

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
  name: sonataflow-platform-example
  namespace: example-namespace
spec:
  persistence:
    postgresql:
      serviceRef:
        name: postgres-example 
1

        namespace: postgres-example-namespace 
2

        databaseName: example-database 
3

        port: 1234 
4

      secretRef:
        name: postgres-secrets-example 
5

        userKey: POSTGRESQL_USER 
6

        passwordKey: POSTGRESQL_PASSWORD 
7

    dataIndex:
      enabled: true
      persistence:
        dbMigrationStrategy: job 
8

    jobService:
      enabled: true
      persistence:
        dbMigrationStrategy: service 
9
1
Name of the Kubernetes service to connect to the PostgreSQL database server.
2
(Optional) Namespace containing the PostgreSQL service. Defaults to the SonataFlowPlatform namespace.
3
Name of the PostgreSQL database to store supporting services and workflows data.
4
(Optional) Port to connect to the PostgreSQL service. Defaults to 5432.
5
Name of the Kubernetes Secret that contains database credentials.
6
Secret key that stores the database username.
7
Secret key that stores the database password.
8
(Optional) Database migration strategy for the Data Index. Defaults to service.
9
(Optional) Database migration strategy for the Jobs Service. Defaults to service. You can configure distinct strategies per service if needed.

5.3.5. Supporting services eventing system configurations

For a OpenShift Serverless Logic installation, the following types of events are generated:

  • Outgoing and incoming events related to workflow business logic.
  • Events sent from workflows to the Data Index and Job Service.
  • Events sent from the Job Service to the Data Index Service.

The OpenShift Serverless Logic Operator leverages the Knative Eventing system to manage all event communication between these events and services, ensuring efficient and reliable event handling.

5.3.5.1. Platform-scoped eventing system configuration

To configure a platform-scoped eventing system, you can use the spec.eventing.broker.ref field in the SonataFlowPlatform CR to reference a Knative Eventing Broker. This configuration instructs the OpenShift Serverless Logic Operator to automatically link the supporting services to produce and consume events by using the specified broker.

A workflow deployed in the same namespace with the preview or gitops profile and without a custom eventing system configuration, automatically links to a specified broker.

Important

In production environments, use a production-ready broker, such as the Knative Kafka Broker, for enhanced scalability and reliability.

The following example displays how to configure the SonataFlowPlatform CR for 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

        namespace: example-broker-namespace 
2

        apiVersion: eventing.knative.dev/v1
        kind: Broker
1
Specifies the Knative Eventing Broker name.
2
Optional: Defines the namespace of the Knative Eventing Broker. If you do not specify a value, the parameter defaults to the SonataFlowPlatform namespace. Consider creating the Broker in the same namespace as SonataFlowPlatform.

5.3.5.2. Service-scoped eventing system configuration

A service-scoped eventing system configuration allows for fine-grained control over the eventing system, specifically for the Data Index or the Job Service.

Note

For a OpenShift Serverless Logic installation, consider using a platform-scoped eventing system configuration. The service-scoped configuration is intended for advanced use cases only.

5.3.5.3. Data Index eventing system configuration

To configure a service-scoped eventing system for the Data Index, you must use the spec.services.dataIndex.source.ref field in the SonataFlowPlatform CR to refer to a specific Knative Eventing Broker. This configuration instructs the OpenShift Serverless Logic Operator to automatically link the Data Index to consume SonataFlow system events from that Broker.

Important

In production environments, use a production-ready broker, such as the Knative Kafka Broker, for enhanced scalability and reliability.

The following example displays the Data Index eventing system configuration:

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
  name: sonataflow-platform-example
spec:
  services:
    dataIndex:
      source:
        ref:
          name: data-index-source-example-broker 
1

          namespace: data-index-source-example-broker-namespace 
2

          apiVersion: eventing.knative.dev/v1
          kind: Broker
1
Specifies the Knative Eventing Broker from which the Data Index consumes events.
2
Optional: Defines the namespace of the Knative Eventing Broker. If you do not specify a value, the parameter defaults to the SonataFlowPlatform namespace. Consider creating the broker in the same namespace as SonataFlowPlatform.

5.3.5.4. Job Service eventing system configuration

To configure a service-scoped eventing system for the Job Service, you must use the spec.services.jobService.source.ref and spec.services.jobService.sink.ref fields in the SonataFlowPlatform CR. These fields instruct the OpenShift Serverless Logic Operator to automatically link the Job Service to consume and produce SonataFlow system events, based on the provided configuration.

Important

In production environments, use a production-ready broker, such as the Knative Kafka Broker, for enhanced scalability and reliability.

The following example displays the Job Service eventing system configuration:

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
  name: sonataflow-platform-example
spec:
  services:
    jobService:
      source:
        ref:
          name: jobs-service-source-example-broker 
1

          namespace: jobs-service-source-example-broker-namespace 
2

          apiVersion: eventing.knative.dev/v1
          kind: Broker
      sink:
        ref:
          name: jobs-service-sink-example-broker 
3

          namespace: jobs-service-sink-example-broker-namespace 
4

          apiVersion: eventing.knative.dev/v1
          kind: Broker
1
Specifies the Knative Eventing Broker from which the Job Service consumes events.
2
Optional: Defines the namespace of the Knative Eventing Broker. If you do not specify a value, the parameter defaults to the SonataFlowPlatform namespace. Consider creating the Broker in the same namespace as SonataFlowPlatform.
3
Specifies the Knative Eventing Broker on which the Job Service produces events.
4
Optional: Defines the namespace of the Knative Eventing Broker. If you do not specify a value, the parameter defaults to the SonataFlowPlatform namespace. Consider creating the Broker in the same namespace as SonataFlowPlatform.

5.3.5.5. Cluster-scoped eventing system configuration for supporting services

When you deploy cluster-scoped supporting services, the supporting services automatically link to the Broker specified in the SonataFlowPlatform CR, which is referenced by the SonataFlowClusterPlatform CR.

The OpenShift Serverless Logic Operator follows a defined order of precedence to configure the eventing system for a supporting service.

Eventing system configuration precedence rules are as follows:

  1. If the supporting service has its own eventing system configuration, using either the Data Index eventing system or the Job Service eventing system configuration, then supporting service configuration takes precedence.
  2. If the SonataFlowPlatform CR enclosing the supporting service is configured with a platform-scoped eventing system, that configuration takes precedence.
  3. If the current cluster is configured with a cluster-scoped eventing system, that configuration takes precedence.
  4. f none of the previous configurations exist, the supporting service delivers events by direct HTTP calls.

5.3.5.7. Eventing system linking configuration

The OpenShift Serverless Logic Operator automatically creates Knative Eventing, SinkBindings, and triggers to link supporting services with the eventing system. These objects enable the production and consumption of events by the supporting services.

The following example displays the Knative Native eventing objects created for the SonataFlowPlatform CR:

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
Used by the Data Index, Job Service, and workflows, unless overridden.
2
Data Index ephemeral deployment, configures the Data Index service.
3
Job Service ephemeral deployment, configures the Job Service.

The following example displays how to configure a Knative Kafka Broker for use with the SonataFlowPlatform CR:

Example of Knative Kafka Broker example used by the SonataFlowPlatform CR

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
Use the Kafka class to create a Kafka Knative Broker.

The following command displays the list of triggers set up for the Data Index and Job Service events, showing which services are subscribed to the events:

$ oc get triggers -n example-namespace

Example output

NAME                                                        BROKER           SINK                                                       AGE   CONDITIONS   READY   REASON
data-index-jobs-fbf285df-c0a4-4545-b77a-c232ec2890e2        example-broker   service:sonataflow-platform-example-data-index-service     106s  7 OK / 7    True    -
data-index-process-definition-e48b4e4bf73e22b90ecf7e093ff6b1eaf   example-broker   service:sonataflow-platform-example-data-index-service     106s  7 OK / 7    True    -
data-index-process-error-fbf285df-c0a4-4545-b77a-c232ec2890e2   example-broker   service:sonataflow-platform-example-data-index-service     106s  7 OK / 7    True    -
data-index-process-instance-mul35f055c67a626f51bb8d2752606a6b54   example-broker   service:sonataflow-platform-example-data-index-service     106s  7 OK / 7    True    -
data-index-process-node-fbf285df-c0a4-4545-b77a-c232ec2890e2      example-broker   service:sonataflow-platform-example-data-index-service     106s  7 OK / 7    True    -
data-index-process-state-fbf285df-c0a4-4545-b77a-c232ec2890e2     example-broker   service:sonataflow-platform-example-data-index-service     106s  7 OK / 7    True    -
data-index-process-variable-ac727d6051750888dedb72f697737c0dfbf   example-broker   service:sonataflow-platform-example-data-index-service     106s  7 OK / 7    True    -
jobs-service-create-job-fbf285df-c0a4-4545-b77a-c232ec2890e2    example-broker   service:sonataflow-platform-example-jobs-service         106s  7 OK / 7    True    -
jobs-service-delete-job-fbf285df-c0a4-4545-b77a-c232ec2890e2    example-broker   service:sonataflow-platform-example-jobs-service         106s  7 OK / 7    True    -

To see the SinkBinding resource for the Job Service, use the following command:

$ oc get sources -n example-namespace

Example output

NAME                                          TYPE          RESOURCE                           SINK                    READY
sonataflow-platform-example-jobs-service-sb   SinkBinding   sinkbindings.sources.knative.dev   broker:example-broker   True

5.3.6. Advanced supporting services configuration options

In scenarios where you must apply advanced configurations for supporting services, use the podTemplate field in the SonataFlowPlatform custom resource (CR). This field allows you to customize the service pod deployment by specifying configurations like the number of replicas, environment variables, container images, resource requirements, and initialization options.

You can configure advanced settings for the service by using the following example:

Advanced configurations example for the Data Index service

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
  name: sonataflow-platform-example
  namespace: example-namespace
spec:
  services:
    dataIndex:
      enabled: true
      podTemplate:
        replicas: 2
        container:
          env:
            - name: <any_advanced_config_property>
              value: <any_value>
          image:
          resources:
            limits:
              cpu:
              memory:
            requests:
              cpu:
              memory:
        initContainers:
# ...

Note

You can set either spec.services.dataIndex or spec.services.jobService depending on your requirement. The rest of the configuration remains the same.

This configuration includes the following settings:

  • replicas - Defines the number of replicas. Default value is 1. In the case of jobService, this value is always overridden to 1 because it operates as a singleton service.
  • container - Holds specific configurations for the container running the service.
  • env - Allows you to fine-tune service properties by specifying environment variables.
  • image - Configures the container image for the service, useful if you need to update or customize the image.
  • resources.limits.cpu - Configures the CPU limit. Default value is 200m.
  • resources.limits.memory - Configures the memory limit. Default value is 1Gi.
  • resources.requests.cpu - Configures the CPU request. Default value is 100m.
  • resources.requests.memory - Configures the memory request. Default value is 1Gi.
  • initContainers - Configures init containers for the pod, useful for setting up prerequisites before the main container starts.
Note

The podTemplate field provides flexibility for tailoring the deployment of each supporting service. It follows the standard PodSpec API, meaning the same API validation rules apply to these fields.

5.3.6.1. Configuring horizontal pod autoscaling for Data Index

By using a HorizontalPodAutoscaler (HPA), you can configure how a Kubernetes workload resource scales based on a set of metrics, such as CPU or memory usage.

You can configure horizontal pod autoscaling for the Data Index service to automatically scale based on resource utilization. The Job Service does not support autoscaling because it operates as a singleton service.

Important

This feature requires OpenShift Serverless Logic 1.38 or later and is not available in earlier versions.

Prerequisites

  • You have deployed a SonataFlowPlatform custom resource (CR) with the Data Index service enabled.
  • You have configured resource requests for the Data Index service.

Procedure

  1. Determine the Data Index deployment name:

    The deployment name follows the pattern: <sonataflowplatform-name>-data-index-service.

    For example, if your SonataFlowPlatform CR is named sonataflow-platform-example, the deployment name is sonataflow-platform-example-data-index-service.

  2. Create a HorizontalPodAutoscaler CR that targets the Data Index deployment:

    apiVersion: autoscaling/v2
    kind: HorizontalPodAutoscaler
    metadata:
      name: data-index-example-autoscaler
      namespace: example-namespace
    spec:
      scaleTargetRef:
        apiVersion: apps/v1
        kind: Deployment
        name: sonataflow-platform-example-data-index-service
      minReplicas: 3
      maxReplicas: 5
      metrics:
        - type: Resource
          resource:
            name: cpu
            target:
              type: Utilization
              averageUtilization: 70

    where:

    • metrics - Defines metrics based on CPU resource utilization.
  3. Apply the HorizontalPodAutoscaler configuration by running the following command:

    $ oc apply -f data-index-autoscaler.yaml -n example-namespace

Verification

  • Verify that the HPA is configured correctly by running the following command:

    $ oc get hpa -n example-namespace
Note

When the OpenShift Serverless Logic Operator detects a HorizontalPodAutoscaler targeting the Data Index deployment, replica management is delegated to the HPA controller. If you remove the HorizontalPodAutoscaler, the operator resumes control of replica management.

Note

You can configure the HorizontalPodAutoscaler metrics using any of the resource requests automatically configured by the OpenShift Serverless Logic Operator. The default resource values are:

resources:
  limits:
    cpu: 200m
    memory: 1Gi
  requests:
    cpu: 100m
    memory: 1Gi

To modify these default values, configure the resources field in the podTemplate as shown in the advanced configurations example.

Important

Integration with a HorizontalPodAutoscaler (HPA) is supported only for the Data Index service. You must not create an HPA for the Job Service, as it is designed to run as a singleton service. Any HPA configuration targeting the Job Service might cause conflicts with the OpenShift Serverless Logic Operator, because the operator manages the replica count for that service.

5.3.6.2. Configuring pod disruption budgets for Data Index

By using a PodDisruptionBudget (PDB), you can configure the required availability of a Kubernetes Deployment during a voluntary disruption, such as a node drain, in the cluster. This also applies to the Data Index service Deployment.

Important

This feature requires OpenShift Serverless Logic 1.38 or later and is not available in earlier versions.

A PDB limits the number of pods that can be unavailable simultaneously during such disruptions, ensuring that the Data Index maintains the desired level of availability.

In general, any tool that needs to guarantee availability should respect the PDB by using the Kubernetes Eviction API instead of directly deleting pods or deployments. The Eviction API ensures that disruption constraints defined by the PDB are honored.

The OpenShift Serverless Logic Operator can automatically generate a PDB for the Data Index based on the SonataFlowPlatform custom resource (CR) configuration.

To configure a PDB for the Data Index, use the spec.services.dataIndex.podTemplate.podDisruptionBudget field in your SonataFlowPlatform CR. The following fields are available:

# ...
spec:
  services:
    dataIndex:
      podTemplate:
        podDisruptionBudget:
          minAvailable: 2
          maxUnavailable: 1
# ...

This configuration includes the following fields:

  • minAvailable - Specifies the number of pods that must still be available after an eviction. This value can be either an absolute number or a percentage, for example 2 or 50%.
  • maxUnavailable - Specifies the number of pods that can be unavailable after an eviction. This value can be either an absolute number or a percentage, for example 1 or 50%.
Note

The minAvailable and maxUnavailable fields are mutually exclusive. You must configure only one of these fields. If both fields are specified, the minAvailable value takes precedence.

The semantics of these fields are aligned with the corresponding fields in the Kubernetes PodDisruptionBudget. For more information, see the Pod Disruption Budgets in the Kubernetes documentation.

Important

The podDisruptionBudget configuration and automatic PDB generation are supported only for the Data Index service. Any podDisruptionBudget configuration defined for the Job Service is ignored by the OpenShift Serverless Logic Operator.

The OpenShift Serverless Logic Operator applies the following generation rules for the PDB:

  1. The PDB is generated only if the SonataFlowPlatform CR has the spec.services.dataIndex.podTemplate.podDisruptionBudget field properly configured.
  2. The PDB is generated only if the SonataFlowPlatform CR has the spec.services.dataIndex.podTemplate.replicas field configured with a value greater than 1.
  3. If the Data Index Deployment has a configured HorizontalPodAutoscaler (HPA), the HPA spec.minReplicas value takes precedence over the SonataFlowPlatform CR spec.services.dataIndex.podTemplate.replicas value.
  4. When an HPA is configured, the PDB is generated only if the HPA spec.minReplicas value is greater than 1.
  5. If the Data Index is scaled to zero (that is, spec.services.dataIndex.podTemplate.replicas = 0), no PDB is generated.
Note

If any of the above conditions change after a PDB has been generated, for example, if the Data Index is rescaled to 1, the previously generated PDB is automatically deleted.

Prerequisites

  • You have deployed a SonataFlowPlatform CR with the Data Index service enabled.

Procedure

  1. Configure a PDB for the Data Index in your SonataFlowPlatform CR:

    apiVersion: sonataflow.org/v1alpha08
    kind: SonataFlowPlatform
    metadata:
      name: sonataflow-platform-example
      namespace: example-namespace
    spec:
      services:
        dataIndex:
          enabled: true
          podTemplate:
            replicas: 2
            podDisruptionBudget:
              minAvailable: 1
        jobService:
          enabled: true
    # ...

    This configuration includes the following settings:

    • replicas: 2 - The Data Index runs with 2 replicas.
    • podDisruptionBudget.minAvailable: 1 - The generated PDB ensures that 1 pod must remain available during a disruption.
  2. Apply the configuration by running the following command:

    $ oc apply -f sonataflow-platform-example.yaml -n example-namespace

Verification

  • Verify that the PDB was created by running the following command:

    $ oc get pdb -n example-namespace
    NAME                                                MIN AVAILABLE   MAX UNAVAILABLE   ALLOWED DISRUPTIONS   AGE
    sonataflow-platform-example-data-index-service     1               N/A               1                     5m

Given this configuration, the OpenShift Serverless Logic Operator generates the following PDB for the Data Index:

kind: PodDisruptionBudget
apiVersion: policy/v1
metadata:
  name: sonataflow-platform-example-data-index-service
  namespace: example-namespace
  ownerReferences:
    - apiVersion: sonataflow.org/v1alpha08
      kind: SonataFlowPlatform
      name: sonataflow-platform-example
      uid: 5e94401d-e645-47f6-abd0-5261b471a9d7
      controller: true
      blockOwnerDeletion: true
spec:
  minAvailable: 1
  selector:
    matchLabels:
      sonataflow.org/service: sonataflow-platform-example-data-index-service

This generated PDB has the following characteristics:

  • The PDB has the same name as the Data Index Deployment.
  • The PDB is created in the same namespace as the SonataFlowPlatform CR.
  • The SonataFlowPlatform CR is configured as the PDB owner.
  • The PDB minAvailable field is configured with the value from spec.services.dataIndex.podTemplate.podDisruptionBudget.minAvailable in the SonataFlowPlatform CR.
  • The PDB selector is configured to target the Data Index Deployment pods.

5.3.7. Cluster scoped supporting services

You can define a cluster-wide set of supporting services that can be consumed by workflows across different namespaces, by using the SonataFlowClusterPlatform custom resource (CR). By referencing an existing namespace-specific SonataFlowPlatform CR, you can extend the use of these services cluster-wide.

You can use the following example of a basic configuration that enables workflows deployed in any namespace to utilize supporting services deployed in a specific namespace, such as example-namespace:

Example of a SonataFlowClusterPlatform CR

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowClusterPlatform
metadata:
  name: cluster-platform
spec:
  platformRef:
    name: sonataflow-platform-example 
1

    namespace: example-namespace 
2

1
Specifies the name of the already installed SonataFlowPlatform CR that manages the supporting services.
2
Specifies the namespace of the SonataFlowPlatform CR that manages the supporting services.
Note

You can override these cluster-wide services within any namespace by configuring that namespace in SonataFlowPlatform.spec.services.

Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni sulla documentazione di Red Hat

Legal Notice

Theme

© 2026 Red Hat
Torna in cima