第 9 章 带有 RHPAM Kogito Operator 的 OpenShift 部署选项


创建红帽构建的 Kogito 微服务作为新应用程序的一部分后,您可以使用 Red Hat OpenShift Container Platform Web 控制台来部署微服务。OpenShift Web 控制台中的 RHPAM Kogito Operator 页面指导您完成部署过程。

RHPAM Kogito Operator 支持在 Red Hat OpenShift Container Platform 上构建和部署红帽构建的 Kogito 微服务:

  • Git 源构建和部署
  • 二进制构建和部署
  • 自定义镜像构建和部署
  • 文件构建和部署

9.1. 使用 Git 源构建和 OpenShift Web 控制台在 OpenShift 上部署红帽构建的 Kogito 微服务

RHPAM Kogito Operator 使用以下自定义资源来部署特定于域的微服务(您开发的微服务):

  • KogitoBuild 使用 Git URL 或其他源构建应用程序,并生成运行时镜像。
  • KogitoRuntime 启动运行时镜像,并根据您的要求进行配置。

在大多数情况下,您可以使用标准运行时构建和部署方法从 Git 存储库源在 OpenShift 上部署红帽构建的 Kogito 微服务,如以下步骤所示。

注意

如果您要在本地开发或测试红帽构建的 Kogito 微服务,您可以使用二进制构建、自定义镜像构建或文件构建选项从本地源而不是从 Git 存储库构建和部署。

先决条件

  • 已安装 RHPAM Kogito Operator。
  • 红帽构建的 Kogito 微服务的应用位于可从 OpenShift 环境访问的 Git 存储库中。
  • 您可以使用必要的权限访问 OpenShift Web 控制台,以便创建和编辑 KogitoBuildKogitoRuntime
  • (红帽只构建的 Quarkus)项目的 pom.xml 文件包含以下 quarkus-smallrye-health 扩展的依赖项:此扩展启用了红帽在 OpenShift 上构建 Quarkus 项目所需的 存活度和就绪度探测

    对于 Red Hat 在 OpenShift 上构建 Quarkus 应用程序的小型健康状况依赖项

    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-smallrye-health</artifactId>
    </dependency>

流程

  1. 进入 Operators Installed Operators 并选择 RHPAM Kogito Operator
  2. 要创建红帽构建的 Kogito 构建定义,请在 operator 页面中选择 Kogito Build 选项卡,再点 Create KogitoBuild
  3. 在应用程序窗口中,使用 Form ViewYAML View 来配置构建定义。

    至少,定义以下示例 YAML 文件中显示的应用程序配置:

    红帽构建的 Quarkus 应用程序的 YAML 定义示例,红帽构建的 Kogito 构建

    apiVersion: rhpam.kiegroup.org/v1 # Red Hat build of Kogito API for this service
    kind: KogitoBuild  # Application type
    metadata:
      name: example-quarkus  # Application name
    spec:
      type: RemoteSource
      gitSource:
        uri: 'https://github.com/kiegroup/kogito-examples'  # Git repository containing application (uses default branch)
        contextDir: dmn-quarkus-example  # Git folder location of application

    红帽构建的 Kogito 构建的 Spring Boot 应用程序的 YAML 定义示例

    apiVersion: rhpam.kiegroup.org/v1 # Red Hat build of Kogito API for this service
    kind: KogitoBuild  # Application type
    metadata:
      name: example-springboot  # Application name
    spec:
      runtime: springboot
      type: RemoteSource
      gitSource:
        uri: 'https://github.com/kiegroup/kogito-examples'  # Git repository containing application (uses default branch)
        contextDir: dmn-springboot-example  # Git folder location of application

    注意

    如果您配置了内部 Maven 存储库,您可以将其用作 Maven 镜像服务,并在 Red Hat build of Kogito 构建定义中指定 Maven 镜像 URL 以大大缩短构建时间:

    spec:
      mavenMirrorURL: http://nexus3-nexus.apps-crc.testing/repository/maven-public/

    有关内部 Maven 存储库的更多信息,请参阅 Apache Maven 文档。

  4. 在定义了应用程序数据后,点 Create 生成红帽构建的 Kogito 构建。

    您的应用程序列在 Red Hat build of KogitoBuilds 页面中。您可以选择应用程序名称来查看或修改应用程序设置和 YAML 详情。

  5. 要创建红帽构建的 Kogito 微服务定义,请在 operator 页面中选择 Kogito Runtime 选项卡,再点 Create KogitoRuntime
  6. 在应用程序窗口中,使用 Form ViewYAML View 来配置微服务定义。

    至少,定义以下示例 YAML 文件中显示的应用程序配置:

    红帽构建的 Quarkus 应用程序的 YAML 定义示例,红帽构建的 Kogito 微服务

    apiVersion: rhpam.kiegroup.org/v1 # Red Hat build of Kogito API for this microservice
    kind: KogitoRuntime  # Application type
    metadata:
      name: example-quarkus  # Application name

    红帽构建的 Kogito 微服务的 Spring Boot 应用程序的 YAML 定义示例

    apiVersion: rhpam.kiegroup.org/v1 # Red Hat build of Kogito API for this microservice
    kind: KogitoRuntime  # Application type
    metadata:
      name: example-springboot  # Application name
    spec:
      runtime: springboot

    注意

    在本例中,应用程序从 Git 构建,并使用 KogitoRuntime 部署。您必须确保应用程序名称在 KogitoBuildKogitoRuntime 中相同。

  7. 在定义了应用程序数据后,点 Create 生成红帽构建的 Kogito 微服务。

    您的应用程序在红帽构建的 Kogito 微服务页面中列出。您可以选择应用程序名称来查看或修改应用程序设置以及 YAML 文件的内容。

  8. 在 Web 控制台的左侧菜单中,进入 Builds Builds 来查看应用程序构建的状态。

    您可以选择特定的构建来查看构建详情。

    注意

    对于您为 OpenShift 部署创建的 Kogito 微服务的每个红帽构建,在 web 控制台的 Builds 页面中生成并列出两个构建:传统的运行时构建和 Source-to-Image (S2I)构建,后缀为 -builder。S2I 机制在 OpenShift 构建中构建应用程序,然后将构建的应用传递给下一个 OpenShift 构建,以打包到运行时容器镜像中。红帽构建的 Kogito S2I 构建配置还允许您直接从 OpenShift 平台上的 Git 存储库构建项目。

  9. 应用程序构建完成后,进入 Workloads Deployments 来查看应用程序部署、Pod 状态和其他详情。
  10. 部署红帽构建的 Kogito 微服务后,在 web 控制台的左侧菜单中,进入 Networking Routes 以查看部署的应用程序的访问链接。

    您可以选择应用程序名称来查看或修改路由设置。

    利用应用程序路由,您可以根据需要将红帽构建的 Kogito 微服务与自动化解决方案集成。

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

© 2024 Red Hat, Inc.