The English version of quarkus.io is the official project site. Translated sites are community supported on a best-effort basis.
このページを編集

Deploy {project-name} applications compiled to native executables

You can deploy your native Quarkus applications to OpenShift compiled to native executables by using the Docker build strategy.

You must create a native executable for your application that targets the Linux AMD64 operating system. If your host operating system is different from this, create a native Linux executable by using a container runtime, for example, Docker or Podman.

Your Quarkus project includes pregenerated Dockerfiles with instructions. If you want to use a custom Dockerfile, add the file to the src/main/docker directory or any location inside the module. Additionally, set the path to your Dockerfile by using the quarkus.openshift.native-dockerfile property.

前提条件

  • You have a Linux AMD64 system or an Open Container Initiative (OCI) compatible container runtime, such as Podman or Docker.

  • You have a Quarkus Maven project that includes the quarkus-openshift extension.

  • 正しい OpenShift プロジェクトの名前空間で作業していること

手順

  1. application.properties 設定ファイルで Docker ビルドストラテジーを設定します:

    quarkus.openshift.build-strategy=docker
  2. Enable container-based native builds:

    quarkus.native.container-build=true
  3. Optional: Set the following properties in the application.properties file based on your environment:

    • 信頼されていない証明書を使用している場合は、 KubernetesClient の証明書の信頼を有効にします:

      quarkus.kubernetes-client.trust-certs=true
    • サービスを公開し、 OpenShift ルートを作成するには、以下のプロパティを設定します:

      quarkus.openshift.route.expose=true
    • To use a custom Dockerfile instead of the pregenerated Dockerfiles, set the path to your custom Dockerfile:

      quarkus.openshift.native-dockerfile=<path_to_your_dockerfile>

      For example, to specify a custom Dockerfile named Dockerfile.custom-native:

      quarkus.openshift.native-dockerfile=src/main/docker/Dockerfile.custom-native
    • Specify the container engine:

      • To build a native executable with Podman:

        quarkus.native.container-runtime=podman
      • To build a native executable with Docker:

        quarkus.native.container-runtime=docker
  4. Finally, build the native executable, package, and deploy your application to OpenShift:

    ./mvnw clean package -Pnative -Dquarkus.openshift.deploy=true

検証

  1. Verify that an image stream and a service resource are created, and that the application is deployed. Use the OpenShift web console or the following OpenShift command-line interface (CLI) commands:

    oc get is (1)
    oc get pods (2)
    oc get svc (3)
    1 作成されたイメージストリームを一覧表示します。
    2 現在の OpenShift プロジェクトに関連するポッドを一覧表示します。
    3 Kubernetesサービスをリストアップします。
  1. To get the log output for your application’s pod, run the following command where <pod_name> is the name of the latest pod prefixed with the name of your application:

    oc logs -f <pod_name>