Skip to content

demo banking application written using gRPC microservices

Notifications You must be signed in to change notification settings

sloppycoder/bank-demo

Repository files navigation

A modern microservice based application

This is a demo banking applicaiton built around modern technolgies. The key pillars of this application are:

  • Self-contained microservices deployed into Kubernetes
  • Polyglot applicatoin with microservices written in different languages and communicate with each other over standard network protocols.
  • Every microservice supports observability with metrics and distributed tracing. Use opencensus and Prometheus to be compatbile with both on-premise stack with Jaeger, Prometheus and Elastic; or Stackdriver in GCP.
  • Use Istio service mesh to perform traffic management within and inter kubernetes clusters
  • High performance inter microservice communication with gRPC. The gRPC services can be directly exposed to external client or use Envoy gRPC-Web filter for clients that do not support HTTP/2 natively.

architecture diagram

Modules in this repo

Directory Language Conent
protos protobuf protobuf API definition used in all across the application.
dashboard Go dashboard microservice, calls casa-account services, either v1 or v2, controlled by istio virtualservice configuration
customer-v1 Java customer microservice built using spring boot. It reads customer data stored in MySQL
casa-account-v1 Java casa account microservice built using micronaut framework. It reads account data stored in Cassandra
casa-account-v2 nodejs casa account microservice, only returns dummy data.
ext-cust-svc python a simple http server written using aiohttp to mock an external REST server that provides customer info
load-generator python uses Locust to generate API calls
testdata python generates test data and write them to Cassandra
istio yaml istio manifest files to traffice management
gcp shell script and manifests to provision GKE cluster.

Requirement

The code in this repo has been tested with minikube and GKE. Details below

Local Minikue

Google Kubernetes Engine

Development Tools:

Run with minikube

Below are steps tesed on Ubutnu Bionic and Focal, should work on other linux flavors too.

Get prerequites first

  1. Install minikube
  2. Download Istio from 1.4.8 from Istio release pages from Github
  3. Install Skaffold
  4. Get Evans gRPC utility from Github release pages

first, then

#
# the k8s and istio versions below matches to versions in GKE's regular channel
#

# start minikube. for 
minikube start \
   --driver=kvm2 \
   --disk-size='30000mb' \
   --cpus='2' \
   --memory='12000mb' \
   --kubernetes-version='1.16.8'

# install istio with auto mTLS enabled
cd istio-1.4.8
bin/istioctl manifest apply --set profile=demo \
  --set values.global.mtls.auto=true \
  --set values.global.mtls.enabled=true

# istio takes sometime to get installed, wait till all the 
# pods are in Running status

# expose port 31400 for use grpc services
# this port is enabled on GCP and later versions of Istio
kubectl patch svc istio-ingressgateway -n istio-system \
--type='json' \
-p='[{"op":"add","path":"/spec/ports/0",  value: {"name": "tcp", "port":31400,"targetPort":31400, "protocol":"TCP"}}]'

#
# come back to this directory and run all the services 
# the script should build and start microservices
./deploy

# if all goes well, you should see output similiar to the one below
{
  "customer": {
    "customerId": "10001000",
    "loginName": "10001000"
  }
}

Roadmap

  1. better integration of logging and tracing. ability to navigate from trace to log with high accuracy. (implemeneted logic for adding data to trace span, and use custom data, e.g. login_name to search trace span. same custom data is added to log entries)
  2. use an external OpenID Connect provide for authentication.
  3. enable mTLS for inter microservice communication. (done)
  4. use Istio for oauth token validation