3.3. 管理支持服务


本节概述 OpenShift Serverless Logic 所必需的支持服务。它专门用于使用 OpenShift Serverless Logic Operator 配置和部署数据索引服务和作业服务支持服务。

在典型的 OpenShift Serverless Logic 安装中,您必须部署这两个服务来确保成功执行工作流。Data Index 服务允许高效的数据管理,而作业服务则可确保可靠的作业处理。

3.3.1. 支持服务和工作流集成

当您在给定命名空间中部署支持服务时,您可以选择启用或禁用的部署。启用的部署会向 OpenShift Serverless Logic Operator 发出信号,以使用命名空间中的 previewgitops 配置集自动截获工作流部署,并将它们配置为与服务连接。

例如,当启用 Data Index 服务时,工作流会自动配置为向它发送状态更改事件。同样,启用作业服务可确保每当工作流需要超时时创建作业。OpenShift Serverless Logic Operator 还配置作业服务,将事件发送到 Data Index 服务,从而促进服务间的无缝集成。

OpenShift Serverless Logic Operator 不仅部署支持服务,它还管理其他必要的配置,以确保工作流成功执行。所有这些配置都会自动处理。您只需要在 SonataFlowPlatform CR 中提供支持服务配置。

注意

仅部署其中一个支持服务或使用禁用的部署是高级用例。在标准安装中,您必须启用这两个服务来确保平稳执行工作流。

3.3.2. 使用 SonataFlowPlatform CR 支持服务部署

要部署支持服务,请在 SonataFlowPlatform 自定义资源(CR)的 spec.services 部分中配置 dataIndexjobService 子字段。此配置指示 OpenShift Serverless Logic Operator 在应用 SonataFlowPlatform CR 时部署每个服务。

服务的每个配置都独立处理,允许您自定义这些设置以及 SonataFlowPlatform CR 中的其他配置。

有关部署支持服务,请参阅以下构建示例配置:

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
Copy to Clipboard Toggle word wrap
1
数据索引服务配置字段。
2
设置 enabled: true 部署 Data Index 服务。如果设置为 false 或 omitted,则部署将被禁用。默认值为 false
3
Job Service 配置字段。
4
设置 enabled: true 部署作业服务。如果设置为 false 或 omitted,则部署将被禁用。默认值为 false

3.3.3. 支持服务范围

SonataFlowPlatform 自定义资源(CR)启用在特定命名空间中部署支持服务。这意味着所有自动配置的支持服务和工作流通信都仅限于所部署平台的命名空间。

当不同版本的工作流需要单独的支持服务实例时,此功能特别有用。例如,您可以使用其工作流和支持服务以隔离方式部署应用程序,确保它们与其他部署保持相互独立。

3.3.4. 支持服务持久性配置

OpenShift Serverless Logic 中支持服务的持久性配置可以是临时的,也可以是 PostgreSQL,具体取决于您的环境的需求。临时持久性是开发和测试的理想选择,而 PostgreSQL 持久性则用于生产环境。

3.3.4.1. 临时持久性配置

临时持久性使用专用于每个服务的嵌入式 PostgreSQL 数据库。OpenShift Serverless Logic Operator 使用每个服务重启重新创建此数据库,使其仅适用于开发和测试目的。您不需要以下 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
Copy to Clipboard Toggle word wrap

3.3.4.2. PostgreSQL 持久性配置

对于 PostgreSQL 持久性,您必须在集群中设置 PostgreSQL 服务器实例。此实例的管理保留独立于 OpenShift Serverless Logic Operator 控制。要将支持服务与 PostgreSQL 服务器连接,您必须配置适当的数据库连接参数。

您可以使用以下示例在 SonataFlowPlatform CR 中配置 PostgreSQL 持久性:

PostgreSQL 持久性配置示例

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.
Copy to Clipboard Toggle word wrap

1
与 PostgreSQL 数据库服务器连接的服务名称。
2
可选:定义 PostgreSQL Service 的命名空间。默认为 SonataFlowPlatform 命名空间。
3
定义用于存储支持服务数据的 PostgreSQL 数据库的名称。
4
可选:指定存储支持服务数据的模式。默认值为 SonataFlowPlatform 名称,后缀为 with -data-index-service or -jobs-service。例如,s onataflow-platform-example-data-index-service
5
可选:与 PostgreSQL 服务连接的端口号。默认值为 5432
6
定义包含数据库访问的用户名和密码的机密名称。
7
定义机密中的密钥名称,其中包含要与数据库连接的用户名。
8
定义机密中的密钥名称,其中包含要与数据库连接的密码。
注意

您可以使用对应的 persistence 字段独立配置每个服务的持久性。

运行以下命令,创建 secret 以访问 PostgreSQL:

$ oc create secret generic <postgresql_secret_name> \
  --from-literal=POSTGRESQL_USER=<user> \
  --from-literal=POSTGRESQL_PASSWORD=<password> \
  -n <namespace>
Copy to Clipboard Toggle word wrap

3.3.4.3. 常见的 PostgreSQL 持久性配置

OpenShift Serverless Logic Operator 会自动将支持服务连接到 spec.persistence 字段中配置的通用 PostgreSQL 服务器。

对于规则,以下优先级适用:

  • 如果您为支持服务配置特定的持久性,如 services.dataIndex.persistence,它会使用该配置。
  • 如果没有为服务配置持久性,系统将使用当前平台的通用持久性配置。
注意

使用通用 PostgreSQL 配置时,每个服务模式会自动设置为 SonataFlowPlatform 名称,后缀为 with -data-index-service-jobs-service,例如 sonataflow-platform-example-data-index-service

3.3.5. 高级支持服务配置

如果需要为支持服务应用高级配置,请在 SonataFlowPlatform 自定义资源(CR)中使用 podTemplate 字段。此字段允许您通过指定副本数、环境变量、容器镜像和初始化选项等配置来自定义服务 pod 部署。

您可以使用以下示例为服务配置高级设置:

Data Index 服务的高级配置示例

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
  name: sonataflow-platform-example
  namespace: example-namespace
spec:
  services:
    # This can be either 'dataIndex' or 'jobService'
    dataIndex:
      enabled: true
      podTemplate:
        replicas: 2 
1

        container: 
2

          env: 
3

            - name: <any_advanced_config_property>
              value: <any_value>
          image: 
4

        initContainers: 
5
Copy to Clipboard Toggle word wrap

注意

您可以根据您的要求,将 'services' 字段设置为 'dataIndex' 或 'jobService'。其余的配置保持不变。

1
定义副本数量。默认值为 1。如果是 jobService,则该值始终被覆盖到 1,因为它作为单例服务运行。
2
包含运行该服务的容器的具体配置。
3
允许您通过指定环境变量来微调服务属性。
4
为服务配置容器镜像,如果您需要更新或自定义镜像,则很有用。
5
为 pod 配置 init 容器,有助于在主容器启动前设置先决条件。
注意

podTemplate 字段提供定制每个支持服务部署的灵活性。它遵循标准 PodSpec API,即相同的 API 验证规则适用于这些字段。

3.3.6. 集群范围内的支持服务

您可以使用 SonataFlowClusterPlatform 自定义资源(CR)定义一组集群范围的支持服务,供不同命名空间中的工作流使用。通过引用特定于命名空间的 SonataFlowPlatform CR,您可以对集群范围内扩展这些服务。

您可以使用以下基本配置示例,它允许在任何命名空间中部署的工作流使用在特定命名空间中部署的支持服务,如 example-namespace

SonataFlowClusterPlatform CR 示例

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

    namespace: example-namespace 
2
Copy to Clipboard Toggle word wrap

1
指定已安装的 SonataFlowPlatform CR 的名称,用于管理支持服务。
2
指定管理支持服务的 SonataFlowPlatform CR 的命名空间。
注意

您可以通过在 SonataFlowPlatform.spec.services 中配置该命名空间来覆盖任何命名空间中的这些集群范围的服务。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat