10.3. 使用自定义镜像构建和 OpenShift Web 控制台在 OpenShift 上部署 Red Hat Kogito 微服务


您可以使用自定义镜像构建作为在 OpenShift 中构建和部署 Kogito 微服务的替代选择。

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

  • KogitoRuntime 启动运行时镜像,并根据要求进行配置。

先决条件

  • 已安装 RHPAM Kogito Operator。
  • 您可以访问 OpenShift Web 控制台,具有创建并编辑 KogitoRuntime 所需的权限。
  • (仅红帽构建的 Quarkus)项目的 pom.xml 文件包含了对 quarkus-smallrye-health 扩展的以下依赖项。此扩展启用 OpenShift 中红帽构建 Quarkus 项目所需的 存活度和就绪度探测

    在 OpenShift 中红帽构建的 Quarkus 应用程序的 SmallRye Health 依赖项

    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-smallrye-health</artifactId>
    </dependency>
    Copy to Clipboard Toggle word wrap

流程

  1. 本地构建应用程序。
  2. 在项目根目录中创建 Containerfile 并包含以下内容:

    Red Hat build of Quarkus 应用程序的 Containerfile 示例

    FROM registry.redhat.io/rhpam-7/rhpam-kogito-runtime-jvm-rhel8:7.11.0
    
    ENV RUNTIME_TYPE quarkus
    
    COPY target/quarkus-app/lib/ $KOGITO_HOME/bin/lib/
    COPY target/quarkus-app/*.jar $KOGITO_HOME/bin
    COPY target/quarkus-app/app/ $KOGITO_HOME/bin/app/
    COPY target/quarkus-app/quarkus/ $KOGITO_HOME/bin/quarkus/
    Copy to Clipboard Toggle word wrap

    Spring Boot 应用程序的 Containerfile 示例

    FROM registry.redhat.io/rhpam-7/rhpam-kogito-runtime-jvm-rhel8:7.11.0
    
    ENV RUNTIME_TYPE springboot
    
    COPY target/<application-jar-file> $KOGITO_HOME/bin
    Copy to Clipboard Toggle word wrap

    • application-jar-file 是应用的 JAR 文件的名称。
  3. 使用以下命令构建 Kogito 镜像的红帽构建:

    podman build --tag <final-image-name> -f <Container-file>
    Copy to Clipboard Toggle word wrap

    在上一命令中,final-image-name 是 Red Hat build of Kogito 镜像,Container-file 是您在上一步中创建的 Containerfile 的名称。

  4. 另外,还可使用以下命令测试构建的镜像:

    podman run --rm -it -p 8080:8080 <final-image-name>
    Copy to Clipboard Toggle word wrap
  5. 使用以下命令将构建的 Red Hat build of Kogito 镜像推送到镜像 registry:

    podman push <final-image-name>
    Copy to Clipboard Toggle word wrap
  6. 进入 Operators Installed Operators 并选择 RHPAM Kogito Operator
  7. 要创建 Red Hat build of Kogito 微服务定义,请在 operator 页面中选择 Kogito Runtime 选项卡,然后点击 Create KogitoRuntime
  8. 在应用窗口中,使用 Form ViewYAML View 来配置微服务定义。

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

    带有红帽构建的 Kogito 微服务构建的 Red Hat build 的 YAML 定义示例

    apiVersion: rhpam.kiegroup.org/v1 # Red Hat build of Kogito API for this microservice
    kind: KogitoRuntime # Application type
    metadata:
      name: example-quarkus # Application name
    spec:
      image: <final-image-name> # Kogito image name
      insecureImageRegistry: true # Can be omitted when image is pushed into secured registry with valid certificate
    Copy to Clipboard Toggle word wrap

    带有红帽构建的 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:
      image: <final-image-name> # Kogito image name
      insecureImageRegistry: true # Can be omitted when image is pushed into secured registry with valid certificate
      runtime: springboot
    Copy to Clipboard Toggle word wrap

  9. 定义应用程序数据后,点 Create 生成 Red Hat build of Kogito 微服务。

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

  10. 应用程序构建完成后,进入 Workloads Deployments 来查看应用程序部署、pod 状态和其他详情。
  11. 部署完 Red Hat build of Kogito microservice 后,在 web 控制台的左侧菜单中,转至 Networking Routes 以查看对部署的应用程序的访问链接。

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

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

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat