Skip to content

MarcoFontana48/Go-Microservices-CCE

Repository files navigation

ci-cd semantic-release: angular Renovate

How to run the project

how to build and run the entire project (it also builds all images before running):

  • make sure to have docker installed and using dockerhub with kubernetes enabled
  • make sure to have go (version 1.22 or higher) installed and 'hey' installed (https://github.com/rakyll/hey) go install github.com/rakyll/hey@latest
  • move to the project root directory (the directory where this README.md is located)
  • run the following commands to stop any running containers and remove existing images and volumes, then build and run the project:

Kubernetes (production)

If you want to deploy the project on kubernets, run the following commands (then wait some minutes to make sure everything is up and running correctly before running other commands):

kubectl delete -f kubernetes/
kubectl apply -f kubernetes/

to only delete containers

kubectl delete -f k8s-manifest.yaml

to only apply the manifest and run the project:

kubectl apply -f k8s-manifest.yaml

to test if the application is running, you can use the following command (windows), if linux remove the .exe. It sends an health check request to the API Gateway of the application:

curl.exe -X GET http://localhost:31080/health

or

curl http://localhost:31080/health

to check if the application reaches the service from api-gateway:

curl.exe http://localhost:31080/service/health

to check all endpoints that can be reached from the API Gateway, you can use the following command:

curl.exe http://localhost:31080/route

to get metrics from API gateway

curl.exe http://localhost:31080/metrics

to get metrics from the service

curl.exe http://localhost:31080/service/metrics

it is also possible to query prometheus via its browser GUI, connecting to "http://localhost:31090/"

To test the autoscaler, first check if the metrics server is running:

kubectl top nodes
kubectl top pods -n monitoring-app

then run this command on another terminal to watch the horizontal pod autoscaler for the API Gateway:

kubectl get hpa -n monitoring-app --watch

then go back to previous terminal and run this command that uses 'hey' to runs 50 workers that concurrently send requests for 2 minutes to the health endpoint of the API Gateway and then prints metrics about the requests:

hey -c 50 -z 2m http://localhost:31080/health

you should be seeing the number of pods for the API Gateway increasing and decreasing based on the requests sent by 'hey' in the terminal where you ran the watch command.

You can also run the same command for the service:

hey -c 50 -z 2m http://localhost:31080/service/health

Docker (dev)

If you want to use docker, run those commands instead:

docker-compose down --rmi all -v
docker-compose up --build -d

to build and run without removing images:

docker-compose down -v
docker-compose up --build -d

to only build the project and run it in detached mode:

docker-compose up --build -d

to only stop the project and remove all containers, networks, images and volumes created by docker-compose up:

docker-compose down --rmi all -v

to only stop the project and remove only volumes and containers:

docker-compose down -v

to test if the application is running, you can use the following command (windows), if linux remove the .exe. It sends an health check request to the API Gateway of the application:

curl.exe -X GET http://localhost:8080/health

or

curl http://localhost:8080/health

to check if the application reaches the service from api-gateway:

curl.exe http://localhost:8080/service/health

to check all endpoints that can be reached from the API Gateway, you can use the following command:

curl.exe http://localhost:8080/route

to get metrics from API gateway

curl.exe http://localhost:8080/metrics

to get metrics from the service

curl.exe http://localhost:8080/service/metrics

it is also possible to query prometheus via its browser GUI, connecting to "http://localhost:9090/"

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors