Skip to content

telepresenceio/emojivoto

 
 

Repository files navigation

Emojivoto

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 a Kubernetes Cluster

Deploy the application to a Kubernetes Cluster

  1. Inject, Deploy, and Enjoy

    make kustomize | kubectl apply -f -
  2. Use the app!

If you're using Minikube

minikube -n emojivoto service web

If you're using Telepresence

telepresence connect -n emojivoto
telepresence serve web

In docker-compose

It's also possible to run the app with docker-compose.

Build and run:

make deploy-to-docker-compose

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

Via URL

To deploy standalone to an existing cluster:

kubectl apply -k github.com/telepresenceio/emojivoto/kustomize/deployment

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.
  • When not voting for 🍩, 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

Building

Building requires that you have protoc-gen-go v1.27.1 and protoc-gen-go-grpc v1.1.0 on your path. These can be installed by running:

go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2

Then you can set up proto files and build apps by running:

make build

Prometheus Metrics

By default the voting service exposes Prometheus metrics about current vote count on port 8801.

This can be disabled by unsetting the PROM_PORT environment variable.

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/cmd/server.go

[In a separate terminal window] Start the emoji service

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

[In a separate terminal 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 terminal 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

View emojivoto

open http://localhost:8080

About

Example application to help demonstrate the Linkerd service mesh

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Go 86.8%
  • CSS 7.9%
  • JavaScript 3.9%
  • Makefile 1.3%
  • Dockerfile 0.1%