This project is a simple demonstration of microservices using Springboot integrated with Zipkin. It is a simple project that lists quotes from Marvel movies and users can vote which one of them they like.
The application then tally the votes.
- Kubernetes cluster (ex. microk8s )
- Docker
- Skaffold
- Helm
- Maven
- jib-maven-plugin
Main components are:
-
frontend/
- Hosts the web pages as well as RESTful access to backend services. -
quotes/
- This component retrieves the Marvel character quotes data stored PostgresSQL. -
votes/
- This component keeps track of the votes on each quote. -
bot/
- The bot will randomly vote quotes to simmulate traffic into the kit. -
bot-go/
- Golang version of bot. -
protos/
- Keeps allproto
files in one location. -
db/
- Contains all infrastructure related components such as PostgreSQL, Redis and flyway (to perform schema migrate).db/postgres
- Postgres kubernetes manifests.db/redis
- Redis kubernetes manifests.db/schema-migrate/
- Flyway schema migration manifests. Run as KubernetesJob
.
-
zipkin/
- Stashes all Zipkin kubernetes manifests.
This is a springboot application that has a simple GUI, which calls the quote service to retrieve all the quotes, calls vote
service to cast and tally votes.
The frontend exposed these REST endpoints.
/api/quote/list
/api/vote/castVote
/api/vote/tally
UI style is brought to you by Material Kit
Go to the directory frontend/
To build the project, do a mvn clean install jib:dockerBuild
For simplicity, you can also use the provided skaffold.yaml
and run skaffold run -p local
or skaffold dev -p local
if you want continuous build and deploy to you local cluster.
You can use Postman to test the frontend's RESTFul endpoints.
This is another springboot application that retrieves quotes stored in PostgreSQL. It uses gRPC java for communication.
Stacks:
- Springboot - 2.1.5.RELEASE
- Lognet grpc-springboot-starter
Go to directory quotes
To build the project, do a mvn clean install jib:dockerBuild
In order to run the quotes
service, you need to have the Quotes DB up and running.
Use skaffold:
- Start the quotes DB (postgres)
skaffold run -p quotes-db-local
- Start the quotes service
skaffold run -p local
Checkout the skaffold.yaml
.
You can use grpcurl to test it from command line.
To get all quotes
grpcurl -plaintext localhost:50052 org.bal.vote.proto.internal.QuoteManagement/AllQuotes
To get quote by Id:
grpcurl -plaintext -d '{"quoteId":"0"}' localhost:50052 org.bal.vote.proto.internal.QuoteManagement/GetQuoteById
This is another springboot application that allows users to cast their favorite Marvel quotes. It also tallies all the votes.
It uses gRPC java for communication.
It stores its data in Redis.
Stacks:
- Springboot - 2.1.5.RELEASE
- Lognet grpc-springboot-starter
- Redis
To build the project, do a mvn clean install jib:dockerBuild
For simplicity, you can also use the provided skaffold.yaml
and run skaffold run -p local
or skaffold dev -p local
if you want continuous build and deploy to you local cluster.
In order to run the votes
service, you need to have the Quotes DB up and running.
Use skaffold:
- Start the Votes DB (Redis)
skaffold run -p votes-db-local
- Start the vote service
skaffold run -p local
Checkout the skaffold.yaml
.
You can use grpcurl to test it from command line.
To get the votes tally
grpcurl -plaintext localhost:50052 org.bal.vote.proto.internal.VoteManagement/GetAllVotes
To cast a vote:
grpcurl -plaintext -d '{"quoteId":"0"}' localhost:50052 org.bal.vote.proto.internal.VoteManagement/CastVote
helm upgrade --install loki loki/loki --namespace monitoring
helm upgrade --install promtail loki/promtail --set "loki.serviceName=loki --namespace monitoring"
To start Zipkin
skaffold run -p local
To stop Zipkin
skaffold delete -p local
Checkout the skaffold.yaml
.
The build uses a Dockerfile. Hence, docker daemon setup is required.