第10章 RHPAM Kogito Operator を使用した OpenShift デプロイメントオプション
ビジネスアプリケーションの一部として Red Hat ビルドの Kogito マイクロサービスを作成したら、Red Hat OpenShift Container Platform Web コンソールを使用してマイクロサービスをデプロイすることができます。OpenShift Web コンソールの RHPAM Kogito Operator ページで、デプロイメントプロセスを進めます。
RHPAM Kogito Operator は、Red Hat OpenShift Container Platform で Red Hat ビルドの Kogito マイクロサービスをビルドしてデプロイするための以下のオプションをサポートします。
- Git ソースビルドおよびデプロイメント
- バイナリービルドおよびデプロイメント
- カスタムイメージのビルドおよびデプロイメント
- ファイルビルドおよびデプロイメント
10.1. Git ソースビルドおよび OpenShift Web コンソールを使用した OpenShift への Red Hat ビルドの Kogito マイクロサービスのデプロイ
RHPAM Kogito Operator は以下のカスタムリソースを使用して、開発するマイクロサービス (ドメイン固有のマイクロサービス) をデプロイします。
-
KogitoBuild
は Git URL または他のソースを使用してアプリケーションをビルドし、ランタイムイメージを作成します。 -
KogitoRuntime
はランタイムイメージを起動し、要件に応じて設定します。
ほとんどのユースケースでは、以下の手順のように、標準のランタイムビルドおよびデプロイメント方法を使用して、Git リポジトリーソースから OpenShift に Red Hat ビルドの Kogito マイクロサービスをデプロイできます。
Red Hat ビルドの Kogito マイクロサービスをローカルで開発またはテストする場合は、バイナリービルド、カスタムイメージビルド、またはファイルビルドオプションを使用して、Git リポジトリーではなく、ローカルソースからビルドおよびデプロイできます。
前提条件
- RHPAM Kogito Operator がインストールされている。
- Red Hat ビルドの Kogito マイクロサービスを使用するアプリケーションが OpenShift 環境からアクセス可能な Git リポジトリーにある。
-
OpenShift Web コンソールにアクセスでき、
KogitoBuild
およびKogitoRuntime
の作成および編集に必要なパーミッションが設定されている。 (Red Hat ビルドの Quarkus のみ) プロジェクトの
pom.xml
ファイルにquarkus-smallrye-health
拡張機能の依存関係が含まれる。この拡張機能は、OpenShift の Red Hat ビルドの Quarkus プロジェクトに必要な Liveness および Readiness Probe を有効する。OpenShift 上の Red Hat ビルドの 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!
手順
-
Operators
Installed Operators に移動し、RHPAM Kogito Operator を選択します。 - Red Hat ビルドの Kogito ビルド定義を作成するには、Operator ページで Kogito Build タブを選択し、Create KogitoBuild をクリックします。
アプリケーションウィンドウで、Form View または YAML View を使用してビルド定義を設定します。
少なくとも、以下の YAML ファイルのサンプルに示されるようにアプリケーション設定を定義します。
Red Hat ビルドの Kogito ビルドを使用した Red Hat ビルドの Quarkus アプリケーションの YAML 定義の例
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
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
Copy to Clipboard Copied! Red Hat ビルドの 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
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
Copy to Clipboard Copied! 注記内部 Maven リポジトリーを設定した場合は、Maven ミラーサービスとして使用でき、Red Hat ビルドの Kogito ビルド定義に Maven ミラー URL を指定して、ビルド時間を大幅に短縮できます。
spec: mavenMirrorURL: http://nexus3-nexus.apps-crc.testing/repository/maven-public/
spec: mavenMirrorURL: http://nexus3-nexus.apps-crc.testing/repository/maven-public/
Copy to Clipboard Copied! 内部 Maven リポジトリーの詳細は、Apache Maven ドキュメントを参照してください。
アプリケーションデータを定義したら、Create をクリックして Red Hat ビルドの Kogito ビルドを生成します。
アプリケーションが Red Hat ビルドの KogitoBuilds ページに一覧表示されます。アプリケーション名を選択して、アプリケーション設定および YAML の詳細を表示または変更できます。
- Red Hat ビルドの Kogito マイクロサービス定義を作成するには、Operator ページで Kogito Runtime タブを選択し、Create KogitoRuntime をクリックします。
アプリケーションウィンドウで、Form View または YAML View を使用してマイクロサービス定義を設定します。
少なくとも、以下の YAML ファイルのサンプルに示されるようにアプリケーション設定を定義します。
Red Hat ビルドの Kogito マイクロサービスを使用した Red Hat ビルドの 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
apiVersion: rhpam.kiegroup.org/v1 # Red Hat build of Kogito API for this microservice kind: KogitoRuntime # Application type metadata: name: example-quarkus # Application name
Copy to Clipboard Copied! Red Hat ビルドの 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
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
Copy to Clipboard Copied! 注記この場合、アプリケーションは Git からビルドされ、KogitoRuntime を使用してデプロイされます。アプリケーション名が
KogitoBuild
およびKogitoRuntime
で同じである必要があります。アプリケーションデータを定義したら、Create をクリックして Red Hat ビルドの Kogito マイクロサービスを生成します。
アプリケーションが Red Hat ビルドの Kogito マイクロサービスページに一覧表示されます。アプリケーション名を選択して、アプリケーション設定や YAML ファイルの内容を表示または変更できます。
Web コンソールの左側のメニューで Builds
Builds に移動して、アプリケーションのビルドのステータスを表示します。 特定のビルドを選択して、ビルドの詳細を表示できます。
注記OpenShift デプロイメント用に作成するすべての Red Hat ビルドの Kogito マイクロサービスでは、従来のランタイムビルドと S2I (接尾辞
-builder
) ビルドの 2 つのビルドが生成され、Web コンソールの Builds ページに一覧表示されます。S2I メカニズムは OpenShift ビルドでアプリケーションを構築し、このアプリケーションを次の OpenShift ビルドに渡してランタイムコンテナーイメージにパッケージ化します。Red Hat ビルドの Kogito S2I ビルド設定では、OpenShift プラットフォームの Git リポジトリーから直接プロジェクトをビルドできます。-
アプリケーションのビルドが完了したら、Workloads
Deployments に移動して、アプリケーションのデプロイメント、Pod のステータスなどの情報を表示します。 Red Hat ビルドの Kogito マイクロサービスをデプロイしたら、Web コンソールの左側のメニューの Networking
Routes に移動し、デプロイされたアプリケーションへのアクセスリンクを表示します。 アプリケーション名を選択して、ルート設定を表示または変更できます。
必要に応じてアプリケーションルートを使用すると、Red Hat ビルドの Kogito マイクロサービスはビジネス自動化ソリューションと統合できます。