Supporting Services
This document describes how to configure and deploy the SonataFlow’s Data Index and Job Service supporting services, using the SonataFlow Operator.
In general, in a regular SonataFlow installation you must deploy both services to ensure a successful execution of your workflows. To get more information about each service please read the respective guides.
-
The SonataFlow Operator installed. See Install the SonataFlow Operator guide.
-
A PostgreSQL database service instance. Required if you are planning to use the PostgreSQL persistence configuration for a supporting service.
Supporting Services and Workflow communications
When you deploy a supporting service in a given namespace, you can do it by using an enabled or disabled deployment.
An enabled deployment, signals the SonataFlow Operator to automatically intercept every workflow deployment with the preview
or gitops
profile, in this namespace, and automatically configure it to connect with that service.
For example, if the Data Index is enabled, a workflow will be automatically configured to send workflow status change events to it. And, similar configurations are produced if the Job Service is enabled, to create a Job, every time a workflow requires a timeout. Additionally, the operator will configure the Job Service to send events to the Data Index Service, etc.
As you can see, the operator can not only deploy a supporting service, but also, manage other configurations to ensure the successful execution of a workflow.
Fortunately, all these configurations are managed automatically, and you must only provide the supporting services configuration in the SonataFlowPlatform
CR.
Scenarios where you only deploy one of the supporting services, or configure a disabled deployment, are intended for advanced use cases. In a regular installation, you must normally configure an enabled deployment of both services to ensure a successful execution of your workflows. |
Deploying the supporting services using the SonataFlowPlatform
CR
To deploy the supporting services you must use the sub-fields dataIndex
and jobService
in the SonataFlowPlatform
CR spec.services
.
That information signals the SonataFlow Operator to deploy each service when the SonataFlowPlatform
CR is deployed.
Each service configuration is considered independently, and you can combine these configurations with any other configuration present in the |
The following SonataFlowPlatform
CR fragment shows a scaffold configuration that you can use as reference:
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 | If true, produces an enabled Data Index Service deployment, see. Other cases produce a disabled deployment. The default is false . |
3 | Job Service configuration field. |
4 | If true, produces an enabled Job Service deployment, see. Other cases produce a disabled deployment. The default is false . |
The configuration above produces an ephemeral deployment of each service, see. |
Supporting Services Scope
The SonataFlowPlatform
CR facilitates the deployment of the supporting services with namespace scope.
It means that, all the automatically configured Supporting Services and Workflow communications, are restricted to the namespace of the given platform.
This can be useful, in cases where you need separate supporting service instances for a set of workflows.
For example, a given application can be deployed isolated with its workflows, and the supporting services.
Additionally, using the SonataFlowClusterPlatform
CR it’s possible to configure a cluster scoped deployment of the supporting services.
Configuring the Supporting Services Persistence
Ephemeral persistence configuration
The ephemeral persistence of a service is supported by an embedded PostgreSQL database dedicated to it. That database is re-created by the operator on every service restart. And thus, it’s only recommended for development and testing purposes.
The ephemeral deployment of a service requires no additional configurations than the shown, here.
PostgreSQL persistence configuration
The PostgreSQL persistence of a service is supported by a PostgreSQL server instance that you must previously install on the cluster. The administration of that instance is totally independent of the SonataFlow Operator scope, and to connect a supporting service with it, you must only configure the correct database connection parameters.
The following SonataFlowPlatform
CR fragment shows the configuration options that you must use:
apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
name: sonataflow-platform-example
namespace: example-namespace
spec:
services:
dataIndex:
enabled: true
persistence:
postgresql:
serviceRef:
name: postgres-example (1)
namespace: postgres-example-namespace (2)
databaseName: example-database (3)
databaseSchema: data-index-schema (4)
port: 1234 (5)
secretRef:
name: postgres-secrets-example (6)
userKey: POSTGRESQL_USER (7)
passwordKey: POSTGRESQL_PASSWORD (8)
jobService:
enabled: true
persistence:
postgresql:
# Specific database configuration for the Job Service
# might be included here.
1 | Name of the Kubernetes Service to connect with the PostgreSQL database server. |
2 | (Optional) Kubernetes namespace containing the PostgreSQL Service. Defaults to the SonataFlowPlatform’s local namespace. |
3 | Name of the PostgreSQL database to store the supporting service data. |
4 | (Optional) Name of the PostgreSQL database schema to store the supporting service data.
Defaults to the SonataFlowPlatform’s name , suffixed with -data-index-service or -jobs-service . For example, sonataflow-platform-example-data-index-service . |
5 | (Optional) Port number to connect with the PostgreSQL Service. Defaults to 5432. |
6 | Name of the Kubernetes Secret containing the username and password to connect with the database. |
7 | Name of the Kubernetes Secret key containing the username to connect with the database. |
8 | Name of the Kubernetes Secret key containing the password to connect with the database. |
The persistence of each service can be configured independently by using the respective |
To create the secrets for the example above you can use a command like this:
kubectl create secret generic postgres-secrets-example --from-literal=POSTGRESQL_USER=<user> --from-literal=POSTGRESQL_PASSWORD=<password> -n postgres-example-namespace
Common PostgreSQL persistence configuration
To configure a common PostgreSQL service instance for all the supporting services you must read, Configuring the persistence using the SonataFlowPlatform CR.
In that case, the SonataFlow Operator will automatically connect any of the supporting services with that common server configured in the field spec.persistence
. And, similarly to the workflow’s persistence, the following precedence rules apply:
-
If a supporting service has a configured persistence, for example, the field
services.dataIndex.persistence
is configured. That configuration will apply. -
If a supporting service has no configured persistence, for example, the field
services.dataIndex.persistence
is not set at all, the persistence configuration will be taken from the current platform.
When you use the common PostgreSQL configuration, the database schema for each supporting service is automatically configured as the SonataFlowPlatform’s |
Advanced Supporting Services Configurations
To configure the advanced options for any of the supporting services you must use the podTemplate
field respectively, for example dataIndex.podTemplate
:
apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
name: sonataflow-platform-example
namespace: example-namespace
spec:
services:
dataIndex:
enabled: true
podTemplate:
replicas: 2 (1)
container: (2)
env: (3)
- name: ANY_ADVANCED_CONFIG_PROPERTY
value: any-value
image: (4)
initContainers: (5)
1 | Number of replicas. Defaults to 1. In the case of the jobService this value is always overridden to 1 by the operator, since that service is a singleton service. |
2 | Holds the particular configurations for the container that will execute the given supporting service. |
3 | Standard Kubernetes env configuration. This can be useful in cases where you need to fine tune any of the supporting services properties. |
4 | Standard Kubernetes image configuration. This can be useful in cases where you need to use an updated image for any of the supporting services. |
5 | Standard Kubernetes initContainers for the Pod that executes the supporting service. |
The |
Cluster Scoped Supporting Services
The SonataFlowClusterPlatform
CR is optionally used to specify a cluster-wide set of supporting services for workflow consumption.
This is done by referencing an existing, namespaced SonataFlowPlatform
CR.
Following is a basic configuration that allows workflows, deployed in any namespace, to leverage supporting services deployed in the chosen example-namespace
namespace.
apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowClusterPlatform
metadata:
name: cluster-platform
spec:
platformRef:
name: sonataflow-platform-example (1)
namespace: example-namespace (2)
1 | Name of the already installed SonatataFlowPlatform CR that configures the supporting services. |
2 | Namespace of the already installed SontataFlowPlatform CR that configures the supporting services. |
These cluster-wide services can be overridden in any namespace, by configuring that namespace’s |
Conclusions
The SonataFlow Operator extends its scope to manage the lifecycle of the Data Index and Job Service instances, thus removing the burden on the users and allowing them to focus on the implementation of the workflows. It takes care also of managing all the configurations to facilitate communication between the workflows and the supporting services. Additionally, it can manage different persistence options for each service, and advanced configurations.
Found an issue?
If you find an issue or any misleading information, please feel free to report it here. We really appreciate it!