Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Quarkus: A quick-start guide to the Kubernetes-native Java stack

November 11, 2019
Daniel Oh
Related topics:
JavaKubernetes
Related products:
Red Hat OpenShift

    As immutable infrastructure was starting to hit its stride four or five years ago, one question Java developers were struggling with was: "How do my microservices have to be optimized in Linux container architecture like faster startup and smaller memory footprint?"

    There were a number of limitations to transforming container-native, microservices-based Java technology at the time. One major reason was that the traditional cloud Java stack had to process most of the required tasks, such as annotation scanning, parsing descriptors at runtime rather than build time, until Quarkus came along.

    Quarkus is a Kubernetes-native Java stack tailored for GraalVM and OpenJDK HotSpot. It’s crafted from best-of-breed Java libraries and standards with the following benefits:

    • A cohesive platform for optimized developer joy
      • Live coding and unified configuration
      • No-hassle native executable generation
    • Container-first and Kubernetes-native Java stack
      • Superfast to startup (i.e., 0.055 Seconds for REST + CRUD)
      • Small memory footprint (i.e., 35 MB for REST + CRUD)
    • Unifies Imperative and Reactive development in the same application
      • Inject the EventBus or the Vertx context
      • Use the technology that fits your use-case
      • Key for reactive systems based on event driven apps
    • Extensions for the latest popular open source projects
    Open source logos

    Start coding

    Let’s get started to develop a simple microservice application to expose the REST endpoint from scratch.

    Bootstrapping the project

    Go to Start Coding page in Quarkus.io to bootstrap the first Quarkus application using RESTEasy JAX-RS and REST Clients Extensions:

    Screenshot of steps

    It generates a ZIP file with:

    • The Maven structure
    • An org.acme.ExampleResource resource exposed on /hello
    • An associated unit test
    • A landing page that is accessible on http://localhost:8080 after starting the application
    • Example Dockerfile files for both native and jvm modes
    • The application configuration file

    Unzip and review skeleton codes via your preferred IDE (i.e., VSCode) like:

    unzip code-with-quarkus.zip && cd code-with-quarkus
    code .

    Once you’ve opened an IDE, look at the pom.xml. You will find the import of the Quarkus BOM, allowing you to omit the version on the different Quarkus dependencies. Additionally, you can see the quarkus-maven-plugin responsible for the packaging of the application and for providing the development mode.

    You can see the quarkus-maven-plugin responsible for the packaging of the application and for providing the development mode.

    Running the application using development mode

    To run the application, you need:

    • JDK 1.8+ installed with JAVA_HOME configured appropriately
    • Apache Maven 3.5.3+

    Now you are ready to run your application. Use: mvn compile quarkus:dev:

    INFO] Scanning for projects...
    INFO] ---------------------< org.acme:code-with-quarkus >---------------------
    [INFO] Building code-with-quarkus 1.0.0-SNAPSHOT
    [INFO] --------------------------------[ jar ]---------------------------------
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ code-with-quarkus ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 2 resources
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ code-with-quarkus ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO] 
    [INFO] --- quarkus-maven-plugin:1.0.0.CR1:dev (default-cli) @ code-with-quarkus ---
    Listening for transport dt_socket at address: 5005
    2019-11-09 08:03:20,900 INFO  [io.qua.dep.QuarkusAugmentor] (main) Beginning quarkus augmentation
    2019-11-09 08:03:21,685 INFO  [io.qua.dep.QuarkusAugmentor] (main) Quarkus augmentation completed in 785ms
    2019-11-09 08:03:22,125 INFO  [io.quarkus] (main) Quarkus 1.0.0.CR1 started in 1.364s. Listening on: http://0.0.0.0:8080
    2019-11-09 08:03:22,126 INFO  [io.quarkus] (main) Profile dev activated. Live Coding activated.
    2019-11-09 08:03:22,126 INFO  [io.quarkus] (main) Installed features: [cdi, resteasy]
    

    Once the application has started, open a web browser to request the provided endpoint: http://localhost:8080/hello

    Once started, open a web browser to request the provided endpoint:  http://localhost:8080/hello

    Change codes

    Modify the return string to “Welcome, Quarkus Cheat Sheet” in hello() method. Remember to save the file:

    public String hello() {
        return "Welcome, Quarkus Cheat Sheet";
    }

    Go back to the web browser then reload the page. The application will be redeployed magically without restarting the runtime:

    The application will be redeployed magically without restarting the runtime.

    Hit CTRL+C to stop the application, but you can also keep it running and enjoy the blazing fast hot-reload.

    Packaging and run the application

    The application is packaged using mvn clean package -DskipTests. It produces two jar files:

    • code-with-quarkus-1.0.0-SNAPSHOT.jar: Containing just the classes and resources of the projects, it’s the regular artifact produced by the Maven build.
    • code-with-quarkus-1.0.0-SNAPSHOT-runner.jar: An executable jar. Be aware that it’s not an über-jar as the dependencies are copied into the target/lib directory.

    Run the application if the endpoint works at the development mode:

    $ java -jar target/code-with-quarkus-1.0.0-SNAPSHOT-runner.jar
    2019-11-09 08:01:14,240 INFO  [io.quarkus] (main) code-with-quarkus 1.0.0-SNAPSHOT (running on Quarkus 1.0.0.CR1) started in 0.660s. Listening on: http://0.0.0.0:8080
    2019-11-09 08:01:14,289 INFO  [io.quarkus] (main) Profile prod activated. 
    2019-11-09 08:01:14,289 INFO  [io.quarkus] (main) Installed features: [cdi, resteasy]
    
    // Run the curl command in a new terminal 
    $ curl http://localhost:8080/hello
    Welcome, Quarkus Cheat Sheet

    Building a native executable

    Let’s now produce a native executable for our application. It improves the startup time of the application and produces a minimal disk footprint. The executable would have everything to run the application including the "JVM" (shrunk to be just enough to run the application) and the application.

    The executable would have everything to run the application including the "JVM" (shrunk to be just enough to run the application) and the application.

    Install GraalVM and configure the environment

    To build a native executable image, you need:

    • Install GraalVM community edition at least version 19.1.1 in GraalVM web site.
    • Run gu install native-image from your GraalVM directory
    • The GRAALVM_HOME environment variable configured as below:

    Linux:

    export GRAALVM_HOME=$HOME/Development/graalvm/

    macOS:

    export GRAALVM_HOME=$HOME/Development/graalvm/Contents/Home/

    Before going further, be sure that the GRAALVM_HOME environment variable is configured appropriately.

    You will use “native” profile to build a native executable image in the pom.xml:

    You will use “native” profile to build a native executable image in the pom.xml.

    Create a native executable and run it

    Run mvn clean package -DskipTests -Pnative. It will take a few minutes to produce the image:

    
    ...
    [code-with-quarkus-1.0.0-SNAPSHOT-runner:86834]     (clinit):     438.26 ms
    [code-with-quarkus-1.0.0-SNAPSHOT-runner:86834]     universe:   1,174.98 ms
    [code-with-quarkus-1.0.0-SNAPSHOT-runner:86834]      (parse):   2,329.86 ms
    [code-with-quarkus-1.0.0-SNAPSHOT-runner:86834]     (inline):   3,247.13 ms
    [code-with-quarkus-1.0.0-SNAPSHOT-runner:86834]    (compile):  27,917.55 ms
    [code-with-quarkus-1.0.0-SNAPSHOT-runner:86834]      compile:  35,768.02 ms
    [code-with-quarkus-1.0.0-SNAPSHOT-runner:86834]        image:   2,067.69 ms
    [code-with-quarkus-1.0.0-SNAPSHOT-runner:86834]        write:     885.91 ms
    [code-with-quarkus-1.0.0-SNAPSHOT-runner:86834]      [total]:  70,647.15 ms
    [INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 73212ms
    [INFO] ------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------
    [INFO] Total time:  01:17 min
    [INFO] Finished at: 2019-11-09T08:05:40+09:00
    [INFO] ------------------------------------------------------------------
    

    Let’s run the native executable:

    
    ./target/code-with-quarkus-1.0.0-SNAPSHOT-runner
    2019-11-09 08:07:24,786 INFO  [io.quarkus] (main) code-with-quarkus 1.0.0-SNAPSHOT (running on Quarkus 1.0.0.CR1) started in 0.013s. Listening on: http://0.0.0.0:8080
    2019-11-09 08:07:24,787 INFO  [io.quarkus] (main) Profile prod activated. 
    2019-11-09 08:07:24,787 INFO  [io.quarkus] (main) Installed features: [cdi, resteasy]
    

    It takes just 13 milliseconds to run our microservices. You will find the same result exactly when you go back to the web browser then reload the endpoint page:

    You will find the same result exactly when you go back to the web browser then reload the endpoint page.

    Hit CTRL+C to stop the application before moving to the next step.

    Deploying on Kubernetes

    Now, you will deploy the optimized microservice application on immutable infrastructure, Kubernetes cluster. You can install own Kubernetes cluster here.

    Containerize the application

    The project generation has provided a Dockerfile.native in the src/main/docker directory with the following content:

    FROM registry.access.redhat.com/ubi8/ubi-minimal
    WORKDIR /work/
    COPY target/*-runner /work/application
    RUN chmod 775 /work
    EXPOSE 8080
    CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]

    Then, you need to push the Docker image to the image registry of your Kubernetes cluster. Depending on your cluster, there are several ways. For Minikube, execute:

    eval $(minikube docker-env)
    
    docker build -f src/main/docker/Dockerfile.native -t 
    quarkus-cheatsheet/myapp .

    Deploy the application in Kubernetes

    Once the image has been pushed to the Kubernetes image registry, instantiate the application as follows:

    kubectl run quarkus-cheatsheet --image=quarkus-cheatsheet/myapp:latest --port=8080 --image-pull-policy=IfNotPresent
    
    kubectl expose deployment quarkus-cheatsheet --type=NodePort

    The application is now exposed as an internal service. If you are using Minikube, you can access it using:

    curl $(minikube service quarkus-quickstart --url)/hello
    
    Welcome, Quarkus Cheat Sheet

    More Quarkus guides

    • Get started with Quarkus course (estimated time: 10 minutes)
    • Red Hat Developer Quarkus courses
    • Get started with Eclipse Che 7 and Quarkus: An overview
    • Quarkus: Supersonic, subatomic Java
    • From zero to Quarkus and Knative: The easy way
    • Create your first Quarkus project with Eclipse IDE (Red Hat CodeReady Studio)

    The Quarkus site provides additional practical and useful guides on how to develop microservices/cloud-native apps/serverless using Quarkus extensions with common use cases:

    • Contexts and Dependency Injection
    • Using SSL With Native Images
    • Using JWT RBAC
    • Simplified Hibernate ORM with Panache
    • Using Apache Kafka Streams
    • Using Keycloak to Protect JAX-RS Applications
    • Deploying Native Applications on Kubernetes or OpenShift
    • Using OpenTracing and Collecting Metrics
    • Building Applications with Maven
    • Using the Quarkus Extension for Spring DI API
    Last updated: January 13, 2022

    Recent Posts

    • Debugging image mode with Red Hat OpenShift 4.20: A practical guide

    • EvalHub: Because "looks good to me" isn't a benchmark

    • SQL Server HA on RHEL: Meet Pacemaker HA Agent v2 (tech preview)

    • Deploy with confidence: Continuous integration and continuous delivery for agentic AI

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.