Skills up project. Uses the following staff:
- docker compose
- gin-gonic web server
- gorm database ORM
- swag docs generator
- prometheus + grafana
- wrk performance testing tool
- nginx reverse proxy with ssl
export DB_HOST=127.0.0.1 # for local run only, not used by docker
export DB_PORT=5432 # for local run only, not used by docker
export DB_USER=anybody
export DB_PASSWORD=qwerty
export DB_NAME=ego
$ mkdir .cert
# create certificate using any instruction from the internet,
# e.g. https://devopscube.com/create-self-signed-certificates-openssl/
# finally you need to have two files in ./.cert: server.crt & server.key
$ source .env
$ make build
$ ./ego_server
$ source .env
$ docker compose up
$ curl http://localhost:8080/driver/count
$ curl -k https://localhost:8443/driver/count
$ go install github.com/swaggo/swag/cmd/swag@latest
$ make swagger
- Goto: localhost:3000, Login: admin/admin
- Create datasource: Type: Prometheus, URL: http://prometheus:9090
- Import dashboard: grafana.json
- Download wrk image:
docker pull williamyeh/wrk - Generate drivers:
curl http://localhost:8080/testapi/drivers -d '{"count": 1000, "cleanup": true}' - Generate requests:
for (( i=1; i <= 1000; i++ )); do echo "/driver/$i"; done > perftest/paths.txt - Run test:
docker run --rm \
--net=host \
-v `pwd`/perftest:/ego \
williamyeh/wrk -t4 -c100 -d10s -s /ego/script.lua http://localhost:8080/`
Service can be deployed into K8S local cluster. Please see details here.