/emojivoto

Example application to help demonstrate the Linkerd service mesh

Primary LanguageGo

Emoji.voto

A microservice application that allows users to vote for their favorite emoji, and tracks votes received on a leaderboard. May the best emoji win.

The application is composed of the following 3 services:

Emojivoto Topology

Running

In Minikube

Deploy the application to Minikube using the Linkerd2 service mesh.

  1. Install the linkerd CLI
curl https://run.linkerd.io/install | sh
  1. Install Linkerd2
linkerd install | kubectl apply -f -
  1. View the dashboard!
linkerd dashboard
  1. Inject, Deploy, and Enjoy
linkerd inject emojivoto.yml | kubectl apply -f -
  1. Use the app!
minikube -n emojivoto service web-svc

In docker-compose

It's also possible to run the app with docker-compose (without Linkerd2).

Build and run:

make deploy-to-docker-compose

The web app will be running on port 8080 of your docker host.

Generating some traffic

The VoteBot service can generate some traffic for you. It votes on emoji "randomly" as follows:

  • It votes for 🍩 15% of the time.
  • It votes for 💩 20% of the time.
  • When not voting for 🍩 or 💩, it picks an emoji at random

If you're running the app using the instructions above, the VoteBot will have been deployed and will start sending traffic to the vote endpoint.

If you'd like to run the bot manually:

export WEB_HOST=localhost:8080 # replace with your web location
go run emojivoto-web/cmd/vote-bot/main.go

Releasing a new version

To update the docker images:

  1. Update the tag name in common.mk
  2. Update the base image tags in Makefile and Dockerfile
  3. Build base docker image make build-base-docker-image
  4. Build docker images make build
  5. Push the docker images to hub.docker.com
docker login
docker push buoyantio/emojivoto-svc-base:v5
docker push buoyantio/emojivoto-emoji-svc:v5
docker push buoyantio/emojivoto-voting-svc:v5
docker push buoyantio/emojivoto-web:v5
  1. Update emojivoto.yml, docker-compose.yml

Local Development

Emojivoto webapp

This app is written with React and bundled with webpack. Use the following to run the emojivoto go services and develop on the frontend.

Start the voting service

GRPC_PORT=8081 go run emojivoto-voting-svc/cmd/server.go

[In a separate teminal window] Start the emoji service

GRPC_PORT=8082 go run emojivoto-emoji-svc/cmd/server.go

[In a separate teminal window] Bundle the frontend assets

cd emojivoto-web/webapp
yarn install
yarn webpack # one time asset-bundling OR
yarn webpack-dev-server --port 8083 # bundle/serve reloading assets

[In a separate teminal window] Start the web service

export WEB_PORT=8080
export VOTINGSVC_HOST=localhost:8081
export EMOJISVC_HOST=localhost:8082

# if you ran yarn webpack
export INDEX_BUNDLE=emojivoto-web/webapp/dist/index_bundle.js

# if you ran yarn webpack-dev-server
export WEBPACK_DEV_SERVER=http://localhost:8083

# start the webserver
go run emojivoto-web/cmd/server.go

[Optional] Start the vote bot for automatic traffic generation.

export WEB_HOST=localhost:8080
go run emojivoto-web/cmd/vote-bot/main.go