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
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:devNOTE: 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/animals
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 packageIt 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-jarThe application is now runnable using java -jar target/quarkus-app/quarkus-run.jar.
You can create a native executable using:
./mvnw package -PnativeOr, 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=trueYou 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
Create your k3d cluster and registry
k3d registry create registry --port 5000
k3d cluster create -c k8s/dev.yamlPackage your app as docker container and push to local k3d registry:
NOTE: Be sure to package your app as native before
docker build -f src/main/docker/Dockerfile.jvm . -t k3d-registry:5000/demo-quarkus:latest
docker push k3d-registry:5000/demo-quarkus:latestIf push fails because of unresolved host, you can add it manually (c:\windows\system32\drivers\etc\hosts on Windows or /etc/hosts on Linux)
127.0.0.1 k3d-registryThen 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/deployment.yaml
kubectl apply -f k8s/service.yaml
kubectl apply -f k8s/ingress.yamlGive it a few moments and then go to http://demo-quarkus.localhost
Check our helm chart and update dependencies.
helm lint helm/
helm dependency update helm/
Deploy helm chart in the k8s cluster
NOTE: Be sure to remove your old resources
kubectl delete Service demo-quarkus
kubectl delete Deployment demo-quarkus
kubectl delete Ingress demo-quarkushelm install demo-quarkus ./helm
helm list
We can also package helm as artefact for the helm repository:
helm package helm/
Successfully packaged chart and saved it to: .../demo-quarkus-1.0.0.tgz