Rechercher

Ce contenu n'est pas disponible dans la langue sélectionnée.

Chapter 10. OpenShift deployment options with the RHPAM Kogito Operator

download PDF

After you create your Red Hat build of Kogito microservices as part of a business application, you can use the Red Hat OpenShift Container Platform web console to deploy your microservices. The RHPAM Kogito Operator page in the OpenShift web console guides you through the deployment process.

The RHPAM Kogito Operator supports the following options for building and deploying Red Hat build of Kogito microservices on Red Hat OpenShift Container Platform:

  • Git source build and deployment
  • Binary build and deployment
  • Custom image build and deployment
  • File build and deployment

10.1. Deploying Red Hat build of Kogito microservices on OpenShift using Git source build and OpenShift web console

The RHPAM Kogito Operator uses the following custom resources to deploy domain-specific microservices (the microservices that you develop):

  • KogitoBuild builds an application using the Git URL or other sources and produces a runtime image.
  • KogitoRuntime starts the runtime image and configures it as per your requirements.

In most use cases, you can use the standard runtime build and deployment method to deploy Red Hat build of Kogito microservices on OpenShift from a Git repository source, as shown in the following procedure.

Note

If you are developing or testing your Red Hat build of Kogito microservice locally, you can use the binary build, custom image build, or file build option to build and deploy from a local source instead of from a Git repository.

Prerequisites

  • The RHPAM Kogito Operator is installed.
  • The application with your Red Hat build of Kogito microservices is in a Git repository that is reachable from your OpenShift environment.
  • You have access to the OpenShift web console with the necessary permissions to create and edit KogitoBuild and KogitoRuntime.
  • (Red Hat build of Quarkus only) The pom.xml file of your project contains the following dependency for the quarkus-smallrye-health extension. This extension enables the liveness and readiness probes that are required for Red Hat build of Quarkus projects on OpenShift.

    SmallRye Health dependency for Red Hat build of Quarkus applications on OpenShift

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

Procedure

  1. Go to Operators Installed Operators and select RHPAM Kogito Operator.
  2. To create the Red Hat build of Kogito build definition, on the operator page, select the Kogito Build tab and click Create KogitoBuild.
  3. In the application window, use Form View or YAML View to configure the build definition.

    At a minimum, define the application configurations shown in the following example YAML file:

    Example YAML definition for a Red Hat build of Quarkus application with Red Hat build of Kogito build

    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

    Example YAML definition for a Spring Boot application with Red Hat build of Kogito build

    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

    Note

    If you configured an internal Maven repository, you can use it as a Maven mirror service and specify the Maven mirror URL in your Red Hat build of Kogito build definition to shorten build time substantially:

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

    For more information about internal Maven repositories, see the Apache Maven documentation.

  4. After you define your application data, click Create to generate the Red Hat build of Kogito build.

    Your application is listed in the Red Hat build of KogitoBuilds page. You can select the application name to view or modify application settings and YAML details.

  5. To create the Red Hat build of Kogito microservice definition, on the operator page, select the Kogito Runtime tab and click Create KogitoRuntime.
  6. In the application window, use Form View or YAML View to configure the microservice definition.

    At a minimum, define the application configurations shown in the following example YAML file:

    Example YAML definition for a Red Hat build of Quarkus application with Red Hat build of Kogito microservices

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

    Example YAML definition for a Spring Boot application with Red Hat build of Kogito microservices

    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

    Note

    In this case, the application is built from Git and deployed using KogitoRuntime. You must ensure that the application name is same in KogitoBuild and KogitoRuntime.

  7. After you define your application data, click Create to generate the Red Hat build of Kogito microservice.

    Your application is listed in the Red Hat build of Kogito microservice page. You can select the application name to view or modify application settings and the contents of the YAML file.

  8. In the left menu of the web console, go to Builds Builds to view the status of your application build.

    You can select a specific build to view build details.

    Note

    For every Red Hat build of Kogito microservice that you create for OpenShift deployment, two builds are generated and listed in the Builds page in the web console: a traditional runtime build and a Source-to-Image (S2I) build with the suffix -builder. The S2I mechanism builds the application in an OpenShift build and then passes the built application to the next OpenShift build to be packaged into the runtime container image. The Red Hat build of Kogito S2I build configuration also enables you to build the project directly from a Git repository on the OpenShift platform.

  9. After the application build is complete, go to Workloads Deployments to view the application deployments, pod status, and other details.
  10. After your Red Hat build of Kogito microservice is deployed, in the left menu of the web console, go to Networking Routes to view the access link to the deployed application.

    You can select the application name to view or modify route settings.

    With the application route, you can integrate your Red Hat build of Kogito microservices with your business automation solutions as needed.

10.2. Deploying Red Hat build of Kogito microservices on OpenShift using binary build and OpenShift web console

OpenShift builds can require extensive amounts of time. As a faster alternative for building and deploying your Red Hat build of Kogito microservices on OpenShift, you can use a binary build.

The operator uses the following custom resources to deploy domain-specific microservices (the microservices that you develop):

  • KogitoBuild processes an uploaded application and produces a runtime image.
  • KogitoRuntime starts the runtime image and configures it as per your requirements.

Prerequisites

  • The RHPAM Kogito Operator is installed.
  • The oc OpenShift CLI is installed and you are logged in to the relevant OpenShift cluster. For oc installation and login instructions, see the OpenShift documentation.
  • You have access to the OpenShift web console with the necessary permissions to create and edit KogitoBuild and KogitoRuntime.
  • (Red Hat build of Quarkus only) The pom.xml file of your project contains the following dependency for the quarkus-smallrye-health extension. This extension enables the liveness and readiness probes that are required for Red Hat build of Quarkus projects on OpenShift.

    SmallRye Health dependency for Red Hat build of Quarkus applications on OpenShift

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

Procedure

  1. Build an application locally.
  2. Go to Operators Installed Operators and select RHPAM Kogito Operator.
  3. To create the Red Hat build of Kogito build definition, on the operator page, select the Kogito Build tab and click Create KogitoBuild.
  4. In the application window, use Form View or YAML View to configure the build definition.

    At a minimum, define the application configurations shown in the following example YAML file:

    Example YAML definition for a Red Hat build of Quarkus application with Red Hat build of Kogito build

    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: Binary

    Example YAML definition for a Spring Boot application with Red Hat build of Kogito build

    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: Binary

  5. After you define your application data, click Create to generate the Red Hat build of Kogito build.

    Your application is listed in the Red Hat build of KogitoBuilds page. You can select the application name to view or modify application settings and YAML details.

  6. Upload the built binary using the following command:

    $ oc start-build example-quarkus --from-dir=target/ -n namespace
    • from-dir is equals to the target folder path of the built application.
    • namespace is the namespace where KogitoBuild is created.
  7. To create the Red Hat build of Kogito microservice definition, on the operator page, select the Kogito Runtime tab and click Create KogitoRuntime.
  8. In the application window, use Form View or YAML View to configure the microservice definition.

    At a minimum, define the application configurations shown in the following example YAML file:

    Example YAML definition for a Red Hat build of Quarkus application with Red Hat build of Kogito microservices

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

    Example YAML definition for a Spring Boot application with Red Hat build of Kogito microservices

    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

    Note

    In this case, the application is built locally and deployed using KogitoRuntime. You must ensure that the application name is same in KogitoBuild and KogitoRuntime.

  9. After you define your application data, click Create to generate the Red Hat build of Kogito microservice.

    Your application is listed in the Red Hat build of Kogito microservice page. You can select the application name to view or modify application settings and the contents of the YAML file.

  10. In the left menu of the web console, go to Builds Builds to view the status of your application build.

    You can select a specific build to view build details.

  11. After the application build is complete, go to Workloads Deployments to view the application deployments, pod status, and other details.
  12. After your Red Hat build of Kogito microservice is deployed, in the left menu of the web console, go to Networking Routes to view the access link to the deployed application.

    You can select the application name to view or modify route settings.

    With the application route, you can integrate your Red Hat build of Kogito microservices with your business automation solutions as needed.

10.3. Deploying Red Hat build of Kogito microservices on OpenShift using custom image build and OpenShift web console

You can use custom image build as an alternative for building and deploying your Red Hat build of Kogito microservices on OpenShift.

The operator uses the following custom resources to deploy domain-specific microservices (the microservices that you develop):

  • KogitoRuntime starts the runtime image and configures it as per your requirements.
Note

The Red Hat Process Automation Manager builder image does not supports native builds. However, you can perform a custom build and use Containerfile to build the container image as shown in the following example:

FROM registry.redhat.io/rhpam-7-tech-preview/rhpam-kogito-runtime-native-rhel8:7.13.5

ENV RUNTIME_TYPE quarkus

COPY --chown=1001:root target/*-runner $KOGITO_HOME/bin

This feature is Technology Preview only.

To build the native binary with Mandrel, see Compiling your Quarkus applications to native executables.

Prerequisites

  • The RHPAM Kogito Operator is installed.
  • You have access to the OpenShift web console with the necessary permissions to create and edit KogitoRuntime.
  • (Red Hat build of Quarkus only) The pom.xml file of your project contains the following dependency for the quarkus-smallrye-health extension. This extension enables the liveness and readiness probes that are required for Red Hat build of Quarkus projects on OpenShift.

    SmallRye Health dependency for Red Hat build of Quarkus applications on OpenShift

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

Procedure

  1. Build an application locally.
  2. Create Containerfile in the project root folder with the following content:

    Example Containerfile for a Red Hat build of Quarkus application

    FROM registry.redhat.io/rhpam-7/rhpam-kogito-runtime-jvm-rhel8:7.13.5
    
    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/

    Example Containerfile for a Spring Boot application

    FROM registry.redhat.io/rhpam-7/rhpam-kogito-runtime-jvm-rhel8:7.13.5
    
    ENV RUNTIME_TYPE springboot
    
    COPY target/<application-jar-file> $KOGITO_HOME/bin

    • application-jar-file is the name of the JAR file of the application.
  3. Build the Red Hat build of Kogito image using the following command:

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

    In the previous command, final-image-name is the name of the Red Hat build of Kogito image and Container-file is name of the Containerfile that you created in the previous step.

  4. Optionally, test the built image using the following command:

    podman run --rm -it -p 8080:8080 <final-image-name>
  5. Push the built Red Hat build of Kogito image to an image registry using the following command:

    podman push <final-image-name>
  6. Go to Operators Installed Operators and select RHPAM Kogito Operator.
  7. To create the Red Hat build of Kogito microservice definition, on the operator page, select the Kogito Runtime tab and click Create KogitoRuntime.
  8. In the application window, use Form View or YAML View to configure the microservice definition.

    At a minimum, define the application configurations shown in the following example YAML file:

    Example YAML definition for a Red Hat build of Quarkus application with Red Hat build of Kogito microservices

    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

    Example YAML definition for a Spring Boot application with Red Hat build of Kogito microservices

    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. After you define your application data, click Create to generate the Red Hat build of Kogito microservice.

    Your application is listed in the Red Hat build of Kogito microservice page. You can select the application name to view or modify application settings and the contents of the YAML file.

  10. After the application build is complete, go to Workloads Deployments to view the application deployments, pod status, and other details.
  11. After your Red Hat build of Kogito microservice is deployed, in the left menu of the web console, go to Networking Routes to view the access link to the deployed application.

    You can select the application name to view or modify route settings.

    With the application route, you can integrate your Red Hat build of Kogito microservices with your business automation solutions as needed.

10.4. Deploying Red Hat build of Kogito microservices on OpenShift using file build and OpenShift web console

You can build and deploy your Red Hat build of Kogito microservices from a single file, such as a Decision Model and Notation (DMN), Drools Rule Language (DRL), or properties file, or from a directory with multiple files. You can specify a single file from your local file system path or specify a file directory from a local file system path only. When you upload the file or directory to an OpenShift cluster, a new Source-to-Image (S2I) build is automatically triggered.

The operator uses the following custom resources to deploy domain-specific microservices (the microservices that you develop):

  • KogitoBuild generates an application from a file and produces a runtime image.
  • KogitoRuntime starts the runtime image and configures it as per your requirements.

Prerequisites

  • The RHPAM Kogito Operator is installed.
  • The oc OpenShift CLI is installed and you are logged in to the relevant OpenShift cluster. For oc installation and login instructions, see the OpenShift documentation.
  • You have access to the OpenShift web console with the necessary permissions to create and edit KogitoBuild and KogitoRuntime.

Procedure

  1. Go to Operators Installed Operators and select RHPAM Kogito Operator.
  2. To create the Red Hat build of Kogito build definition, on the operator page, select the Kogito Build tab and click Create KogitoBuild.
  3. In the application window, use Form View or YAML View to configure the build definition.

    At a minimum, define the application configurations shown in the following example YAML file:

    Example YAML definition for a Red Hat build of Quarkus application with Red Hat build of Kogito build

    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: LocalSource

    Example YAML definition for a Spring Boot application with Red Hat build of Kogito build

    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: LocalSource

    Note

    If you configured an internal Maven repository, you can use it as a Maven mirror service and specify the Maven mirror URL in your Red Hat build of Kogito build definition to shorten build time substantially:

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

    For more information about internal Maven repositories, see the Apache Maven documentation.

  4. After you define your application data, click Create to generate the Red Hat build of Kogito build.

    Your application is listed in the Red Hat build of KogitoBuilds page. You can select the application name to view or modify application settings and YAML details.

  5. Upload the file asset using the following command:

    $ oc start-build example-quarkus-builder --from-file=<file-asset-path> -n namespace
    • file-asset-path is the path of the file asset that you want to upload.
    • namespace is the namespace where KogitoBuild is created.
  6. To create the Red Hat build of Kogito microservice definition, on the operator page, select the Kogito Runtime tab and click Create KogitoRuntime.
  7. In the application window, use Form View or YAML View to configure the microservice definition.

    At a minimum, define the application configurations shown in the following example YAML file:

    Example YAML definition for a Red Hat build of Quarkus application with Red Hat build of Kogito microservices

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

    Example YAML definition for a Spring Boot application with Red Hat build of Kogito microservices

    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

    Note

    In this case, the application is built from a file and deployed using KogitoRuntime. You must ensure that the application name is same in KogitoBuild and KogitoRuntime.

  8. After you define your application data, click Create to generate the Red Hat build of Kogito microservice.

    Your application is listed in the Red Hat build of Kogito microservice page. You can select the application name to view or modify application settings and the contents of the YAML file.

  9. In the left menu of the web console, go to Builds Builds to view the status of your application build.

    You can select a specific build to view build details.

    Note

    For every Red Hat build of Kogito microservice that you create for OpenShift deployment, two builds are generated and listed in the Builds page in the web console: a traditional runtime build and a Source-to-Image (S2I) build with the suffix -builder. The S2I mechanism builds the application in an OpenShift build and then passes the built application to the next OpenShift build to be packaged into the runtime container image.

  10. After the application build is complete, go to Workloads Deployments to view the application deployments, pod status, and other details.
  11. After your Red Hat build of Kogito microservice is deployed, in the left menu of the web console, go to Networking Routes to view the access link to the deployed application.

    You can select the application name to view or modify route settings.

    With the application route, you can integrate your Red Hat build of Kogito microservices with your business automation solutions as needed.

Red Hat logoGithubRedditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez leBlog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

© 2024 Red Hat, Inc.