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


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

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

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

先决条件

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

    Red Hat build of Quarkus applications on OpenShift

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

流程

  1. 本地构建应用。
  2. 在项目根文件夹中创建 Containerfile,其内容如下:

    红帽构建的 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/

    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

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

    podman build --tag <final-image-name> -f <Container-file>

    在上一命令中,final-image-name 是 Kogito 镜像的红帽构建的名称,Container-file 是您在上一步中创建的 Containerfile 的名称。

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

    podman run --rm -it -p 8080:8080 <final-image-name>
  5. 使用以下命令将构建的 Kogito 镜像推送到镜像 registry:

    podman push <final-image-name>
  6. 进入 Operators Installed Operators,再选择 RHPAM Kogito Operator
  7. 要创建 Kogito 微服务定义的红帽构建,请在 operator 页面中选择 Kogito Runtime 选项卡,然后单击 Create KogitoRuntime
  8. 在应用窗口中,使用 Form ViewYAML View 来配置微服务定义。

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

    红帽构建的带有 Kogito 微服务的 Quarkus 应用程序的 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

    使用红帽构建 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

  9. 定义应用程序数据后,单击 Create 以生成红帽构建 Kogito 微服务。

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

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

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

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

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2026 Red Hat
返回顶部