A Golang Calculator API built with Gorilla Mux Router and Prometheus Metrics ready to deploy to Kubernetes.
To deploy it, run the following command:
kubectl apply -f https://raw.githubusercontent.com/tomweston/tm-calculator/master/kubernetes/manifest.yml
kubectl --namespace=tm-calculator port-forward svc/tm-calculator-service 5555:5555
- GET - 10 random numbers (if no num provided):
curl http://localhost:5555/api/v1/random
- GET - 100 random numbers:
curl http://localhost:5555/api/v1/random?num=100
- GET - Add 20 to 10:
curl http://localhost:9000/api/v1/add?num1=20&num2=10
- GET - Subtract 5 from 10:
curl http://localhost:5555/api/v1/subtract?num1=10&num2=5
- GET - Divide 10 by 2:
curl http://localhost:5555/api/v1/division?num1=10&num2=2
- GET - Readiness:
curl http://localhost:5555/readiness
- GET - Liveness:
curl http://localhost:5555/liveness
go test -v ./...
docker build -t tm-calculator .
docker run -d -p 5555:5555 tm-calculator
go build
./tm-calculator
Metrics curl http://localhost:5555/metrics
processed_adds_total
- The total number of processed add events
processed_subtracts_total
- The total number of processed subtraction events
processed_division_total
- The total number of processed division events
processed_random_total
- The total number of processed random events
kubectl apply -f manifest.yml
kubectl --namespace=tm-calculator port-forward svc/tm-calculator-service 5555:5555