ワンステップでQuarkusアプリケーションをOpenShiftにデプロイ
アプリケーション開発者として、Quarkusアプリケーションをビルドし、OpenShiftにデプロイします。 以下のコマンドのいずれかを実行してください:
quarkus build quarkus deploy openshift
./mvnw install -Dquarkus.openshift.deploy=true
./gradlew build -Dquarkus.openshift.deploy=true
これらのコマンドで、アプリケーションをローカルにビルドし、コンテナイメージのビルドをトリガーし、生成されたOpenShiftリソースを自動的に適用します。
生成されたリソースは Kubernetes Deployment
を使用しますが、 Route
や BuildConfig
などの OpenShift 固有のリソースを使用します。
前提条件
-
OpenJDK 17 以降がインストールされていること
-
環境変数
JAVA_HOME
をJava SDKの場所に設定していること -
OpenShift クラスタにアクセスでき、
oc
CLIツールの最新互換バージョンがインストールされていること -
正しい OpenShift プロジェクトの名前空間で作業していること
このディプロイメントを実行するには、 |
ビルドとデプロイをワンステップで
-
Trigger a build and deployment in a single step:
quarkus build quarkus deploy openshift
./mvnw install -Dquarkus.openshift.deploy=true
./gradlew build -Dquarkus.openshift.deploy=true
If you want to test your application immediately, set the For example, add |
As of OpenShift 4.14, the Because of this change, consider the following:
For more information about the deprecation, how to set up and use automatic rollbacks, triggers, lifecycle hooks, and custom strategies, see the Red Hat Knowledgebase article DeploymentConfig API is being deprecated in Red Hat OpenShift Container Platform 4.14. |
検証
-
Verify that an image stream and a service resource are created and the application is deployed by using the OpenShift web console.
quarkus.container-image.group=<project/namespace name>
Alternatively, run the following OpenShift command-line interface (CLI) commands:
oc get is (1) oc get pods (2) oc get svc (3)
1 List the image streams created. 2 List the pods associated with your current OpenShift project. 3 List the Kubernetes services. -
To get the log output for your application’s pod, enter the following command:
oc logs -f <pod_name>
By default, the service is not exposed to the outside world. Therefore, if you did not expose the created service automatically by setting the
quarkus.openshift.route.expose=true
property before building the application, you can expose the service manually.oc expose svc/openshift-quickstart (1) oc get routes (2) curl http://<route>/hello (3)
1 サービスの公開 2 公開されているルートのリストを取得します。 3 アプリケーションにアクセスします。