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

Chapter 3. Using the Quarkus OpenShift extension to deploy Quarkus applications on OpenShift


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.

Note

Use the Quarkus OpenShift extension for development and testing purposes only. For production environments, consider using the traditional S2I method described in Chapter 4, Using S2I to deploy Quarkus applications on OpenShift.

Procedure

  1. Change to the directory that contains your Quarkus Maven project.
  2. To add the OpenShift extension to an existing project, enter the following command:

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

    You can include the -Dextensions="openshift" argument to add the Quarkus OpenShift extension when you create a new project.

    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, 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 7 image, add the following line to the application.properties file:

    quarkus.s2i.base-jvm-image=registry.access.redhat.com/openjdk/openjdk-11-rhel7
    Copy to Clipboard Toggle word wrap
    Note

    If you are deploying on IBM Z infrastructure, add quarkus.s2i.base-jvm-image=registry.access.redhat.com/openj9/openj9-11-rhel8 to the application.properties file.

  5. To create an OpenShift route, add the following line to the application.properties file:

    quarkus.openshift.expose=true
    Copy to Clipboard Toggle word wrap
  6. Save the changes to the application.properties file.
  7. Log in to the OpenShift CLI (oc):

    oc login
    Copy to Clipboard Toggle word wrap
  8. 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
  9. To deploy your project to OpenShift, enter the following command in your Quarkus Maven project directory:

    ./mvnw clean package -Dquarkus.kubernetes.deploy=true
    Copy to Clipboard Toggle word wrap
  10. To display the names and routes of all deployed applications in the OpenShift project, enter the following command:

    oc get route
    Copy to Clipboard Toggle word wrap
  11. To view the full URL to the application, where APPLICATION_NAME is the name of an application deployed in your OpenShift project, enter the following command:

    export URL="http://$(oc get route APPLICATION_NAME -o jsonpath='{.spec.host}')"
    echo "Application URL: $URL"
    curl $URL/hello
    Copy to Clipboard Toggle word wrap
  12. To create an HTTP request on the route’s hello endpoint, enter the following command:

    curl $URL/hello
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat