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

Chapter 1. Deploying a Serverless Quarkus Java application to OpenShift using the OpenShift extension


The traditional source-to-image (S2I) source workflow generates the deployable artifacts of your application inside OpenShift. The Quarkus OpenShift extension uses the S2I binary workflow to provide a more streamlined deployment process. Instead of building from the source, the extension uploads the JAR files from the local file system. As a result, the build process is up to ten times faster than the traditional S2I method. You can use the Quarkus OpenShift extension when developing locally as well as from a build server or continuous integration (CI) system to perform repeatable builds from source.

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

Prerequisites

  • You have a Quarkus Maven project.
  • OpenShift Serverless operator is installed.
  • OpenShift Knative Serving is installed.
  • You have access to a Red Hat OpenShift Container Platform cluster and the latest version of the OpenShift CLI (oc) is installed.
  • OpenJDK 11 is installed and the JAVA_HOME environment variable specifies the location of the Java SDK.
  • Apache Maven 3.6.2 or higher is installed. Maven is available from the Apache Maven Project website.
  • 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. Add the OpenShift extension to an existing project:

    ./mvnw quarkus:add-extension -Dextensions="openshift"
    Copy to Clipboard Toggle word wrap

    When you add the OpenShift extension, the script adds the following dependency to the pom.xml file:

       <dependency>
    	<groupId>io.quarkus</groupId>
     	<artifactId>quarkus-openshift</artifactId>
       </dependency>
    Copy to Clipboard Toggle word wrap
  3. If you are using an untrusted certificate while in a development or testing environment, add the following line to the src/main/resources/application.properties file:

    quarkus.kubernetes-client.trust-certs=true
    Copy to Clipboard Toggle word wrap
  4. To direct OpenShift to use the Open JDK 11 Red Hat Enterprise Linux 8 image, add the following line to the application.properties file:

    quarkus.s2i.base-jvm-image=registry.access.redhat.com/ubi8/openjdk-11
    Copy to Clipboard Toggle word wrap
  5. To direct OpenShift Serverless to pull your container image from the OpenShift internal registry, add the following line to the application.properties file:

    quarkus.container-image.registry=image-registry.openshift-image-registry.svc:5000
    Copy to Clipboard Toggle word wrap
  6. To enable the creation of deployment descriptors for Knative Serving, add the following line to the application.properties file:

    quarkus.kubernetes.deployment-target=knative
    Copy to Clipboard Toggle word wrap
  7. Save the changes to the application.properties file.
  8. Log in to the OpenShift CLI (oc):

    oc login
    Copy to Clipboard Toggle word wrap
  9. 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
    Note

    The <project_name> should be the same as the username of the host system otherwise Quarkus cannot pull the image from the image registry. If you set a different <project_name>, make sure to add the following line to the application.properties file:

    quarkus.container-image.group=<project_name>
    Copy to Clipboard Toggle word wrap
  10. To deploy your project to OpenShift, enter the following command:

    ./mvnw clean package -Dquarkus.kubernetes.deploy=true
    Copy to Clipboard Toggle word wrap
  11. To verify that the application was deployed correctly, run the following command:

    kn service list
    Copy to Clipboard Toggle word wrap
  12. To view the full URL to the application, enter the following command where <application_name> is the name of an application deployed in your OpenShift project:

     kn route describe <application_name> -o jsonpath='{.status.url}'
    Copy to Clipboard Toggle word wrap
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2026 Red Hat
返回顶部