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

Chapter 5. Deploying Quarkus applications as an OpenShift Serverless service


You can deploy your Quarkus applications to OpenShift Serverless using the Docker build strategy. 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.

Your Quarkus project includes pre-generated Dockerfiles with instructions. When you want to use a custom Dockerfile, you need to add the file in the src/main/docker directory or anywhere inside the module. Additionally, you need to set the path to your Dockerfile using the quarkus.openshift.jvm-dockerfile property for JVM mode and quarkus.openshift.native-dockerfile property for native mode.

The following procedure demonstrates how to deploy a Serverless Quarkus Java application or a Serverless application compiled to a native executable using the Quarkus OpenShift extension.

Prerequisites

  • Have a Quarkus Maven project that includes the quarkus-openshift extension.
  • Login to OpenShift using oc and select your project.

  • OpenShift Serverless operator is installed.
  • OpenShift Knative Serving is installed and verified. See Installing Knative Serving.
  • For native compilation, a Linux X86_64 operating system or an OCI (Open Container Initiative) compatible container runtime, such as Podman or Docker is required.

Procedure

  1. Change to the directory that contains your Quarkus project.
  2. Configure the following properties in your application.properties file:

    1. Set Knative as a deployment target:

      quarkus.kubernetes.deployment-target=knative
      Copy to Clipboard Toggle word wrap
    2. Set the Docker build strategy:

      quarkus.openshift.build-strategy=docker
      Copy to Clipboard Toggle word wrap
    3. Direct OpenShift Serverless to pull your container image from the OpenShift internal registry:

      quarkus.container-image.registry=image-registry.openshift-image-registry.svc:5000
      Copy to Clipboard Toggle word wrap
      Note

      If your OpenShift <project_name> is different from the username of the host system, set the group for the container image otherwise Quarkus cannot pull the image from the image registry.

      quarkus.container-image.group=<project_name>
      Copy to Clipboard Toggle word wrap
    4. (Optional) If you are using an untrusted certificate, configure the KubernetesClient:

      quarkus.kubernetes-client.trust-certs=true
      Copy to Clipboard Toggle word wrap
    5. (Optional) Expose the service to create an OpenShift route:

      quarkus.openshift.expose=true
      Copy to Clipboard Toggle word wrap
    6. (Optional) Set the path to your custom Dockerfile:

      quarkus.openshift.jvm-dockerfile=<path_to_your_dockerfile>
      Copy to Clipboard Toggle word wrap

      The following example shows the path to the Dockerfile.custom-jvm:

      quarkus.openshift.jvm-dockerfile=src/main/resources/Dockerfile.custom-jvm
      Copy to Clipboard Toggle word wrap
  3. (Optional) To deploy a Serverless application compiled to a native executable, you need to configure the following properties:

    1. Set the container runtime:

      quarkus.native.container-build=true
      Copy to Clipboard Toggle word wrap
    2. Specify the container engine:

      • To build a native executable with Podman:

        quarkus.native.container-runtime=podman
        Copy to Clipboard Toggle word wrap
      • To build a native executable with Docker:

        quarkus.native.container-runtime=docker
        Copy to Clipboard Toggle word wrap
    3. (Optional) Set the path to your custom Dockerfile:

      quarkus.openshift.native-dockerfile=<path_to_your_dockerfile>
      Copy to Clipboard Toggle word wrap
  4. Package and deploy your Serverless application to OpenShift using one of the following options:

    1. Deploy a Quarkus Java application:

      ./mvnw clean package -Dquarkus.kubernetes.deploy=true
      Copy to Clipboard Toggle word wrap
    2. Deploy a Quarkus native application:

      ./mvnw clean package -Pnative -Dquarkus.kubernetes.deploy=true
      Copy to Clipboard Toggle word wrap

Verification

  1. View a list of pods associated with your current OpenShift project:

    oc get pods
    Copy to Clipboard Toggle word wrap
  2. To retrieve the log output for your application’s pod, enter 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>
    Copy to Clipboard Toggle word wrap
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2026 Red Hat
返回顶部