此内容没有您所选择的语言版本。

Chapter 5. Deploying a Quarkus application compiled to a native executable as a OpenShift Serverless service


As an application developer, you can deploy a Quarkus application compiled to a native executable on Red Hat OpenShift Container Platform using OpenShift Serverless Knative Serving.

By using OpenShift Serverless Knative Serving, you can scale services up and down depending on the load size. Scaling down services that are currently not requested improves memory capabilities.

Note

You can run Quarkus as a native executable or as a Java application using OpenJDK. For native executables, use the Red Hat UBI 8 minimal image. For OpenJDK, use the Red Hat 8 UBI Java image.

You can separate the native build, container build, and deployment steps when deploying a native serverless application. The following procedure demonstrates how to deploy a container image for a Quarkus native application in a continuous integration (CI) as a serverless application.

Prerequisites

  • OpenShift Serverless operator is installed.
  • OpenShift Knative Serving is installed.
  • For native compilation, a container environment like Podman or Docker is required.
  • The kn CLI tool is installed.

Procedure

  1. Change to the directory that contains your Quarkus project.
  2. Build a Linux executable using one of the following methods:

    1. For Docker use:

      ./mvnw package -Pnative -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=registry.access.redhat.com/quarkus/mandrel-20-rhel8:20.3
      Copy to Clipboard Toggle word wrap
    2. For Podman use:

      ./mvnw package -Pnative -Dquarkus.native.container-build=true -Dquarkus.native.container-runtime=podman -Dquarkus.native.builder-image=registry.access.redhat.com/quarkus/mandrel-20-rhel8:20.3
      Copy to Clipboard Toggle word wrap
  3. Open the src/main/docker/Dockerfile.native file and set the <image_name> and <version> parameters:

    1. For Docker use:

      docker build -f src/main/docker/Dockerfile.native -t <image_name>:<version> .
      Copy to Clipboard Toggle word wrap
    2. For Podman use:

      podman build -f src/main/docker/Dockerfile.native -t <image_name>:<version>.
      Copy to Clipboard Toggle word wrap
  4. Push the container to a repository that your CI environment and your OpenShift environment can access, where <registry> is your registry URL:

    1. For Docker use:

      docker tag <image_name>:<version> <registry>/<image_name>:<version>
      docker push <registry>/<image_name>:<version>
      Copy to Clipboard Toggle word wrap
    2. For Podman use:

      podman tag <image_name>:<version> <registry>/<image_name>:<version>
      podman push <registry>/<image_name>:<version>
      Copy to Clipboard Toggle word wrap
  5. Log in to the OpenShift CLI (oc):

    oc login
    Copy to Clipboard Toggle word wrap
  6. To create a new OpenShift project, enter the following command where <project_name> is the name of your new project:

    oc new-project <project_name>
    Copy to Clipboard Toggle word wrap
  7. To deploy your container as a serverless application using the OpenShift Serverless CLI (kn), enter the following command where <service_name> is the name for your service:

    kn service create <service_name> --image REPOSITORY/<image_name>:<version>
    Copy to Clipboard Toggle word wrap
  8. To verify that the service is ready, enter the following command.

    kn service list <service_name>
    Copy to Clipboard Toggle word wrap

    The output in the column called "READY" reads true if the service is ready.

    Note

    The kn service command returns true when the necessary components are created, not when the image is pulled down and ready.

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat