10.3. カスタムイメージビルドおよび OpenShift Web コンソールを使用した Red Hat build of Kogito マイクロサービスの OpenShift へのデプロイ
OpenShift で Red Hat build of Kogito マイクロサービスをビルドし、デプロイする代わりに、カスタムイメージビルドを使用できます。
Operator は以下のカスタムリソースを使用して、開発するマイクロサービス (ドメイン固有のマイクロサービス) をデプロイします。
-
KogitoRuntimeはランタイムイメージを起動し、要件に応じて設定します。
Red Hat Decision Manager ビルダーイメージはネイティブビルドをサポートしません。ただし、以下の例のように、カスタムビルドを実行し、Containerfile を使用してコンテナーイメージをビルドできます。
FROM registry.redhat.io/rhpam-7-tech-preview/rhpam-kogito-runtime-native-rhel8:7.13.4
ENV RUNTIME_TYPE quarkus
COPY --chown=1001:root target/*-runner $KOGITO_HOME/bin
この機能はテクノロジープレビューとしてのみ提供されています。
Mandrel を使用してネイティブバイナリーをビルドするには、Quarkus アプリケーションのネイティブ実行可能ファイルへのコンパイル を参照してください。
前提条件
- RHPAM Kogito Operator がインストールされている。
-
OpenShift Web コンソールにアクセスでき、
KogitoRuntimeの作成および編集に必要なパーミッションが設定されている。 (Red Hat build of Quarkus のみ) プロジェクトの
pom.xmlファイルにquarkus-smallrye-health拡張機能の依存関係が含まれる。この拡張機能は、OpenShift の Red Hat build of Quarkus プロジェクトに必要な Liveness および Readiness Probe を有効にします。OpenShift 上の Red Hat build of Quarkus アプリケーションの SmallRye Health 依存関係
<dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-smallrye-health</artifactId> </dependency>
<dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-smallrye-health</artifactId> </dependency>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
手順
- アプリケーションをローカルに構築します。
以下の内容を含むプロジェクトルートディレクトリーに
Containerfileを作成します。Red Hat build of Quarkus アプリケーションの
Containerfileの例Copy to Clipboard Copied! Toggle word wrap Toggle overflow Spring Boot アプリケーションの
Containerfileの例FROM registry.redhat.io/rhpam-7/rhpam-kogito-runtime-jvm-rhel8:7.13.4 ENV RUNTIME_TYPE springboot COPY target/<application-jar-file> $KOGITO_HOME/bin
FROM registry.redhat.io/rhpam-7/rhpam-kogito-runtime-jvm-rhel8:7.13.4 ENV RUNTIME_TYPE springboot COPY target/<application-jar-file> $KOGITO_HOME/binCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
application-jar-fileは、アプリケーションの JAR ファイルの名前です。
-
以下のコマンドを使用して Red Hat build of Kogito イメージをビルドします。
podman build --tag <final-image-name> -f <Container-file>
podman build --tag <final-image-name> -f <Container-file>Copy to Clipboard Copied! Toggle word wrap Toggle overflow このコマンドでは、
final-image-nameは Red Hat build of Kogito イメージの名前、Container-fileは直前の手順で作成したContainerfileに置き換えます。必要に応じて、以下のコマンドを使用してビルドイメージをテストします。
podman run --rm -it -p 8080:8080 <final-image-name>
podman run --rm -it -p 8080:8080 <final-image-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow 以下のコマンドを使用して、ビルドした Red Hat build of Kogito イメージをイメージレジストリーにプッシュします。
podman push <final-image-name>
podman push <final-image-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Operators
Installed Operators に移動し、RHPAM Kogito Operator を選択します。 - Red Hat build of Kogito マイクロサービス定義を作成するには、Operator ページで Kogito Runtime タブを選択し、Create KogitoRuntime をクリックします。
アプリケーションウィンドウで、Form View または YAML View を使用してマイクロサービス定義を設定します。
少なくとも、以下の YAML ファイルのサンプルに示されるようにアプリケーション設定を定義します。
Red Hat build of Kogito マイクロサービスを使用した Red Hat build of Quarkus アプリケーションの YAML 定義の例
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Red Hat build of Kogito マイクロサービスを使用した Spring Boot アプリケーションの YAML 定義の例
Copy to Clipboard Copied! Toggle word wrap Toggle overflow アプリケーションデータを定義したら、Create をクリックして Red Hat build of Kogito マイクロサービスを生成します。
アプリケーションが Red Hat build of Kogito マイクロサービスページに一覧表示されます。アプリケーション名を選択して、アプリケーション設定や YAML ファイルの内容を表示または変更できます。
-
アプリケーションのビルドが完了したら、Workloads
Deployments に移動して、アプリケーションのデプロイメント、Pod のステータスなどの情報を表示します。 Red Hat build of Kogito マイクロサービスをデプロイしたら、Web コンソールの左側のメニューの Networking
Routes に移動し、デプロイされたアプリケーションへのアクセスリンクを表示します。 アプリケーション名を選択して、ルート設定を表示または変更できます。
必要に応じてアプリケーションルートを使用すると、Red Hat build of Kogito マイクロサービスはビジネス自動化ソリューションと統合できます。