This is the reference project of devon4quarkus.
If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .
The app uses data persistence and you need a working database to use it. We also use tracing and metrics collector.
There is a docker-compose.yaml
in the root of this repo that provides all of them.
You can start the DB and Jaeger containers using simple cmd:
docker-compose up
If you want to use other DB, modify the params in application.properties
.
For using Cloud DBs, refer the steps in AWS DB or Azure DB.
To access Jaeger UI(tracing): http://localhost:16686
To access Prometheus(metrics): http://localhost:9090/graph
To access health check of our app: http://localhost:8080/q/health
You can run your application in dev mode that enables live coding using:
./mvnw compile quarkus:dev
NOTE: Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
You can run tests from your IDE or via Maven. Simply run ./mvnw test
or ./mvnw package
Go to http://localhost:8080/product/v1
With your app running, go to http://localhost:8080/q/swagger-ui to see the Swagger UI visualizing your API. You can access the YAML OpenAPI schema under http://localhost:8080/q/openapi
The application can be packaged using:
./mvnw package
It produces the quarkus-run.jar
file in the target/quarkus-app/
directory.
Be aware that it’s not an über-jar as the dependencies are copied into the target/quarkus-app/lib/
directory.
If you want to build an über-jar, execute the following command:
./mvnw package -Dquarkus.package.type=uber-jar
The application is now runnable using java -jar target/quarkus-app/quarkus-run.jar
.
You can create a native executable using:
./mvnw package -Pnative
Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
./mvnw package -Pnative -Dquarkus.native.container-build=true
You can then execute your native executable with: ./target/demo-quarkus-1.0.0-SNAPSHOT-runner
If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html.
It is recommended to use vanilla maven settings (no custom mirror, proxy) for better performance. If you have modified your default settings ~/.m2/settings.xml
please revert it, or run the maven commands with the clean settings included in this project using -s ./settings.xml
To deploy the application, you need a Kubernetes cluster and a registry from which to pull the application image.
Package your app as docker container and push the image to your local registry:
docker build -f src/main/docker/Dockerfile.jvm . -t your-registry/demo-quarkus:latest
docker push your-registry/demo-quarkus:latest
Also enter the path to your registry in the k8s/application-deployment.yaml
file so that Kubernetes knows where to get the image from. The location to change is marked with a "TODO" comment.
Then apply the k8s resources to your cluster (make sure your kubectl has the correct context first)
kubectl apply -f k8s/postgres-deployment.yaml
kubectl apply -f k8s/postgres-service.yaml
kubectl apply -f k8s/application-deployment.yaml
kubectl apply -f k8s/application-service.yaml
kubectl apply -f k8s/ingress.yaml
Give it a few moments and then open http://demo-quarkus.localhost/products/ in your browser.
- For deploying in AWS EKS Cluster, refer this link.
- For deploying in Azure AKS Cluster, refer this link.
NOTE: Be sure to remove your old resources first
kubectl delete -f k8s
First, in the src/main/helm/values.yaml
file, specify the path to your registry from which you want to obtain the image.
Then you can deploy the application with the following command:
helm install demo-quarkus src/main/helm
This will deploy the application and the corresponding Postgres database. Try it out by opening http://demo-quarkus.localhost/products/ in your browser.
To terminate the instances use the following command:
helm uninstall demo-quarkus
Quarkus can be easily configured to support OpenTelemetry features that can be used in combination with tools such as Jaeger or VictoriaMetrics to monitor traces and metrics. To learn more about OpenTelemetry, see the devonfw architecture browser in the chapter about OpenTelemetry.
The documentation
folder contains a guide with instructions on how to set up the application in combination with these tools.