Questo contenuto non è disponibile nella lingua selezionata.

Chapter 4. Using S2I to deploy Quarkus applications on OpenShift


The traditional source-to-image (S2I) method is widely used as the preferred method for deploying applications on Red Hat OpenShift Container Platform. With S2I, you must provide the source code to the build container either through a Git repository or by uploading the source at build time. Use this method to deploy your Quarkus applications in production environments.

Prerequisites

  • You have a Quarkus Maven project hosted in a Git repository.

Procedure

  1. Change to the directory that contains your Quarkus Maven project.
  2. Create a hidden directory called .s2i at the same level as the pom.xml file.
  3. Create a file called environment in the .s2i directory and add the following content:

    ARTIFACT_COPY_ARGS=-p -r lib/ *-runner.jar
  4. Commit and push your changes to the remote Git repository.
  5. Log in to the OpenShift CLI (oc):

    oc login
  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>
  7. To import the supported OpenShift image, enter the following command:

    oc import-image --confirm ubi8/openjdk-11 --from=registry.access.redhat.com/ubi8/openjdk-11
    Note

    If you are deploying on IBM Z infrastructure, enter oc import-image --confirm openj9/openj9-11-rhel8 --from=registry.redhat.io/openj9/openj9-11-rhel8.

    For information about this image, see the Red Hat OpenJ9 11 Java Applications on RHEL8 page.

  8. To build the project in OpenShift, enter the following command where <git_path> is the path to the Git repository that hosts your Quarkus project and <project_name> is the OpenShift project that you created.

    oc new-app ubi8/openjdk-11 <git_path> --name=<project_name>
    Note

    If you are deploying on IBM Z infrastructure, enter oc new-app openj9/openj9-11-rhel8 <git_path> --name=<project_name>.

    This command builds the project, creates the application, and deploys the OpenShift service.

  9. To create an OpenShift route, enter the following command:

    oc expose service/<project_name>
  10. To view the new route, enter the following command where <application_name> is the name of an application deployed in your OpenShift project:

    export URL="http://$(oc get route <application_name> -o jsonpath='{.spec.host}}')"
    echo "Application URL: $URL"
  11. To create an HTTP request on the route’s hello endpoint, enter the following command:

    curl $URL/hello
  12. To use your application, enter the URL returned in the preceding command in a web browser.
  13. To deploy an updated version of the project, push any updates to the Git repository then enter the following command:

    oc start-build <project_name>
  14. Refresh your browser page after the build completes to see the changes.
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2026 Red Hat
Torna in cima