π₯ eggybytes/events-breakfast-demo π₯
An example of two microservice architectures: a synchronous, coupled request/response approach and an asynchronous, less-coupled event-driven approach.
See the corresponding blog post/talk for more detail on why/how this exists.
- Tools needed to run this whole thing
- Bazelisk for the Go backend
- Minikube setup for the events broker
- Frontend tools for the webapp
- How to build and run
- Clean up and destroy everything
Tools needed
Bazelisk
Set up bazelisk
:
brew tap bazelbuild/tap
brew install bazelisk
Verify that bazel
points to bazelisk
:
$ which bazel
/usr/local/bin/bazel
melinda at mmbp in ~/events on ml-add-bazel*
$ ls -l /usr/local/bin/bazel
lrwxr-xr-x 1 melinda admin 34 May 11 11:33 /usr/local/bin/bazel -> ../Cellar/bazelisk/1.6.1/bin/bazel
Minikube setup
Install minikube, make Hyperkit the default driver, and give it more than the default amount of RAM:
brew install minikube
minikube config set driver hyperkit
minikube config set memory 2048 # 2 GB
To start minikube:
minikube start
To stop minikube:
minikube stop
Frontend tools
Install Yarn and Node if you don't have them.
How to build and run
Deploy Kafka to minikube
This deploys a clean version (nothing specific to this demo) of Kafka and Zookeeper to Kubernetes.
kubectl apply -f deployments/kafka.yaml
Create our Kafka topic
kubectl exec -it kafka-0 -- bash
# from kafka/local/topics.sh
/opt/kafka/bin/kafka-topics.sh --create --partitions 2 --replication-factor 1 --zookeeper zookeeper:2181 --topic order.order
Run the synchronous version of the microservices
bazel run //go/services/order-sync:api
bazel run //go/services/payment:api
bazel run //go/services/delivery:api
Run the asynchronous version of the microservices
bazel run //go/services/order-async:api
bazel run //go/workers/payment:worker
bazel run //go/workers/delivery:worker
Build the webapp
To build e.g. the breakfast-webapp
app (and rebuild on every relevant file change):
yarn build --watch
Serve the webapp
To actually serve the breakfast-webapp
app (won't work unless you build first):
yarn start
Clean up and destroy everything
minikube delete