Clone git repository.
git clone https://github.com/anaxdev/vorto-coffeeshop.git
Build api docker image.
cd vorto-coffeeshop
docker-compose build api
Run system
docker-compose up -d
If everything is ok, http://localhost:8080/
or http://server-address:8080/
should show the API welcome page.
Push API docker image to dockerhub (or any other docker registry).
docker login
docker push anadk/vorto-coffeeshop-api:1.0
Note: docker registry name for api image should be changed according to the own registry.
Create a ConfigMap for database initialization script
kubectl create configmap pg-init-script \
--from-literal=coffee.sql="$(curl -fsSL https://raw.githubusercontent.com/anaxdev/vorto-coffeeshop/main/sql/coffee.sql)"
Deploy all applications into Kubernetes cluster
git clone https://github.com/anaxdev/vorto-coffeeshop.git
cd vorto-coffeeshop
kubectl apply -f ./k8s
There is a postman file grpc_test.postman_collection.json to test API endpoints. Import this file to Postman tool.
API has two endpoints: delivery
and statistics
Endpoint | Method | Parameter:Description | Response |
---|---|---|---|
delivery | Post | bean_type_id : CoffeeBean Id carrierIdStr : Carrier Id supplierIdStr : Supplier Id |
Success (also new delivery is inserted to the table) or Fail with invalid delivery message |
statistics | Get | Return the probability of valid delivery. |
There is a sql file invalid-deliveries.sql that produces the invalid deliveries. (Invalid deliveries are deliveries that a carrier cannot perform due to carrier bean constraints.)
docker exec -i <postgres-container> psql -U postgres postgres < invalid-deliveries.sql
or
Run sql query of this file in postgres client tool.