DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Using Quarkus to Run Java Apps on Kubernetes

Using Quarkus to Run Java Apps on Kubernetes

This developer runs a quick test of the recently announced Quarkus framework from Red Hat.

Niklas Heidloff user avatar by
Niklas Heidloff
CORE ·
Apr. 15, 19 · Tutorial
Like (7)
Save
Tweet
Share
10.73K Views

Join the DZone community and get the full member experience.

Join For Free

a few weeks ago, red hat introduced quarkus, which is a "next-generation kubernetes-native java framework" that is available as open source . quarkus promises really fast boot times and low memory usages. this makes quarkus a perfect fit for java workloads running as microservices on kubernetes as well as java workloads running as serverless functions.

read the article, " why quarkus " to learn how quarkus works. in a nutshell, quarkus compiles java source code in native binaries via graalvm . the quarkus framework helps developers to easily build applications that can leverage the graalvm benefits.

i did some first quick tests to check how difficult it is to use quarkus for my cloud-native starter sample. one of my microservices uses javaee and eclipse microprofile. as documented on the microprofile blog , microprofile can be used together with quarkus.

my sample service is pretty simple and basically provides only a rest api. it uses a "classic" javaee stack. read my article dockerizing java microprofile applications for details about the exact stack i'm using.

what i like most about quarkus is that i can run my existing microprofile application with little changes only!

using quarkus was pretty straight forward. all i had to do was to exchange the dockerfile

from registry.fedoraproject.org/fedora-minimal
workdir /work/
copy target/*-runner /work/application
run chmod 775 /work
expose 8080
cmd ["./application", "-dquarkus.http.host=0.0.0.0"]


...and to change the pom.xml file:

<dependency>
   <groupid>org.eclipse.microprofile</groupid>
   <artifactid>microprofile</artifactid>
   <version>2.1</version>
   <scope>provided</scope>
   <type>pom</type>
</dependency>
<dependency>
   <groupid>io.quarkus</groupid>
   <artifactid>quarkus-arc</artifactid>
</dependency>
<dependency>
   <groupid>io.quarkus</groupid>
   <artifactid>quarkus-resteasy</artifactid>
   <version>0.11.0</version>
</dependency>


in order to deploy the quarkus service to kubernetes, i wrote a little script . in the first step, the java code is compiled via graalvm into a native binary. after this, a docker image is built that contains and runs the native binary on a 'fedora-minimal' image.

mvn -f ${root_folder}/articles-java-jee/pom-quarkus.xml package -pnative -dnative-image.docker-build=true
docker build -f ${root_folder}/articles-java-jee/dockerfile.quarkus -t articles-quarkus:1 .
kubectl apply -f deployment/kubernetes-quarkus.yaml


after this i can run the "classic" articles service and the quarkus-based version in the same way.


the results are amazing. the size of the "classic" image is 462 mb, while the quarkus image is only 128 mb big.

note : i haven't optimized the "classic" stack at all. for example, i included many features i don't really need. keep this in mind for the comparison.


in my local minikube cluster, the startup time of the classic container (including ssl certificate creation, openapi explorer, etc.) took 5 seconds, while quarkus started in 0.003 seconds.


more interesting than the startup time of the containers is the overall duration, how long it takes to create a new kubernetes deployment ( kubectl apply ...yaml ). i haven't done extensive testing, but here are some interesting numbers. i measured the time how long it takes for minikube to start both containers (including the istio proxy) in the pod after the images have been built and pushed. for the "classic" version this takes roughly 46 seconds, for the quarkus based version it takes about 6 seconds only.

if you want to give it a try yourself, check out my repo and run the script above.

Quarkus Kubernetes Java (programming language) Docker (software) app

Published at DZone with permission of Niklas Heidloff, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Public Cloud-to-Cloud Repatriation Trend
  • Project Hygiene
  • Last Chance To Take the DZone 2023 DevOps Survey and Win $250! [Closes on 1/25 at 8 AM]
  • The Role of Data Governance in Data Strategy: Part II

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: