The SonataFlowPlatform
custom resource (CR) enables persistence configuration at the namespace level. This approach applies the persistence settings automatically to all workflows deployed in the namespace. It simplifies resource configuration, especially when multiple workflows in the namespace belong to the same application. While this configuration is applied by default, individual workflows in the namespace can override it using the SonataFlow
CR.
The OpenShift Serverless Logic Operator also uses this configuration to set up persistence for supporting services.
|
The persistence configurations are applied only at the time of workflow deployment. Changes to the SonataFlowPlatform CR do not affect workflows that are already deployed.
|
Procedure
-
Define the SonataFlowPlatform
CR.
-
Specify the persistence settings in the persistence
field under the SonataFlowPlatform
CR spec.
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)
1 |
Name of the Kubernetes Service connecting to the PostgreSQL database. |
2 |
Optional: Namespace of the PostgreSQL Service. Defaults to the namespace of the SonataFlowPlatform . |
3 |
Name of the PostgreSQL database for storing workflow data. |
4 |
Optional: Port number to connect to the PostgreSQL service. Defaults to 5432 . |
5 |
Name of the Kubernetes Secret containing database credentials. |
6 |
Key in the Secret object that contains the database username. |
7 |
Key in the Secret object that contains the database password. |
-
View the generated environment variables for the workflow.
The following example shows the generated environment variables for a workflow named example-workflow
deployed with the earlier SonataFlowPlatform
configuration. These configurations specifically relate to persistence and are managed by the OpenShift Serverless Logic Operator. You cannot modify these settings once you have applied them.
|
When you use the SonataFlowPlatform persistence, every workflow is configured to use a PostgreSQL schema name equal to the workflow name.
|
env:
- name: QUARKUS_DATASOURCE_USERNAME
valueFrom:
secretKeyRef:
name: postgres-secrets-example
key: POSTGRESQL_USER
- name: QUARKUS_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-secrets-example
key: POSTGRESQL_PASSWORD
- name: QUARKUS_DATASOURCE_DB_KIND
value: postgresql
- name: QUARKUS_DATASOURCE_JDBC_URL
value: >-
jdbc:postgresql://postgres-example.postgres-example-namespace:1234/example-database?currentSchema=example-workflow
- name: KOGITO_PERSISTENCE_TYPE
value: jdbc
When this persistence configuration is in place, the OpenShift Serverless Logic Operator configures every workflow deployed in this namespace using the preview
or gitops
profile, to connect with the PostgreSQL database by injecting relevant JDBC connection parameters as environment variables.
|
PostgreSQL is currently the only supported database for persistence.
|
For SonataFlow
CR deployments using the preview
profile, the OpenShift Serverless Logic build system automatically includes specific Quarkus extensions required for enabling persistence. This ensures compatibility with persistence mechanisms, streamlining the workflow deployment process.