Skip to content

devonfw-sample/devon4quarkus-reference

Repository files navigation

devon4quarkus cloud native reference project

This is the reference project of devon4quarkus.

If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .

Database & Jaeger & Prometheus

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

Running the application in dev mode

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/.

Running tests

You can run tests from your IDE or via Maven. Simply run ./mvnw test or ./mvnw package

Access your REST endpoint

Go to http://localhost:8080/animals

OpenAPI & Swagger UI

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

Packaging and running the application

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.

Creating a native executable

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.

Maven settings

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

Deploy to kubernetes

Create your k3d cluster and registry

k3d registry create registry --port 5000
k3d cluster create -c k8s/dev.yaml

Package 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:latest

If 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-registry

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/deployment.yaml
kubectl apply -f k8s/service.yaml
kubectl apply -f k8s/ingress.yaml

Give it a few moments and then go to http://demo-quarkus.localhost

Helm

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-quarkus
helm 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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 12

Languages