Skip to content

felipedemacedo/sorveteria-quarkus-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sorveteria-quarkus-api

Downloads

  1. Download and install Java JDK https://www.oracle.com/br/java/technologies/downloads/
  2. Download and install Maven https://maven.apache.org/download.cgi
  3. Download and install PostgreSQL https://www.postgresql.org/download
  4. (optional) Download and install IntelliJ Community (free) https://www.jetbrains.com/pt-br/idea/download/other.html

Step by step for the creation of this repo

1. Run the following command on windows CMD

mvn io.quarkus.platform:quarkus-maven-plugin:3.15.1:create -DprojectGroupId=io.github.felipedemacedo -DprojectArtifactId=sorveteria-quarkus-api

If using Powershell, wrap -D parameters in double quotes e.g. "-DprojectArtifactId=my-artifactId"

2. Install dependencies

   - hibernate-validator
   - jdbc-h2
   - hibernate-orm
   - hibernate-orm-panache
   - resteasy-jsonb

with the following command on CMD:

./mvnw quarkus:add-extension -Dextensions="hibernate-validator,jdbc-h2,hibernate-orm,hibernate-orm-panache,resteasy-jsonb"

Alternatively you can add these lines into pom.xml:

<dependency>
   <groupId>io.quarkus</groupId>
   <artifactId>quarkus-hibernate-validator</artifactId>
</dependency>
<dependency>
   <groupId>io.quarkus</groupId>
   <artifactId>quarkus-jdbc-h2</artifactId>
</dependency>
<dependency>
   <groupId>io.quarkus</groupId>
   <artifactId>quarkus-hibernate-orm</artifactId>
</dependency>
<dependency>
   <groupId>io.quarkus</groupId>
   <artifactId>quarkus-hibernate-orm-panache</artifactId>
</dependency>
<dependency>
   <groupId>io.quarkus</groupId>
   <artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>

3. Install Prometheus for metrics adding these lines into pom.xml:

<dependency>
   <groupId>io.quarkus</groupId>
   <artifactId>quarkus-smallrye-metrics</artifactId>
</dependency>

image

4. Run the following command on windows CMD

./mvnw compile quarkus:dev

The result should be something like this: image

More info here: Using Quarkus with Maven https://quarkus.io/guides/maven-tooling

5. Test project with Postman:

Test Case 1 Test Case 2 Test Case 3
image image image

6. Validate Prometheus is functional

6.1. You may download and install it from: https://prometheus.io/download/

6.2. Modify prometheus.yml pointing it into the endpoint we created (localhost:8080/q/metrics):

scrape_configs:
  - job_name: "prometheus"
    metrics_path: '/q/metrics'
    static_configs:
      - targets: ["localhost:8080"]

6.3. Run prometheus.exe (Windows) and validate api metrics are present.

image

image

7. (optional) Install and use Grafana

7.1. Download it from https://grafana.com/

7.2. Run Grafana Server

image

7.3. Configure it for reading Prometheus as data source

image

8. (optional) Scale it up with Kubernetes

8.1. Download kubectl

https://kubernetes.io/releases/download/#binaries

8.2. Download minikube

https://minikube.sigs.k8s.io/docs/start/?arch=%2Fwindows%2Fx86-64%2Fstable%2F.exe+download

8.3. Download Virtualbox or use Hyper-V

https://www.virtualbox.org/

8.4. Start minikube

minikube start

In case of error, run:

minikube delete
minikube start

Verify status with:

minikube status

image

8.5. (optional) Install VSCode extensions

image

image