forked from datawire/emojivoto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prep emojivoto for move to buoyantio/emojivoto repo (datawire#54)
Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
- Loading branch information
Showing
56 changed files
with
156 additions
and
787 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,142 @@ | ||
![Conduit][conduit-logo] | ||
# Emoji.voto | ||
|
||
# conduit-examples | ||
A microservice application that allows users to vote for their favorite emoji, | ||
and tracks votes received on a leaderboard. May the best emoji win. | ||
|
||
🎈 Welcome to conduit-examples! 👋 | ||
The application is composed of the following 3 services: | ||
|
||
This repo contains subdirectories with examples of how to use the | ||
[Conduit service mesh](https://conduit.io). | ||
* [emojivoto-web](emojivoto-web/): Web frontend and REST API | ||
* [emojivoto-emoji-svc](emojivoto-emoji-svc/): gRPC API for finding and listing emoji | ||
* [emojivoto-voting-svc](emojivoto-voting-svc/): gRPC API for voting and leaderboard | ||
|
||
## Emoji.voto | ||
![Emojivoto Topology](assets/emojivoto-topology.png "Emojivoto Topology") | ||
|
||
* [`emojivoto/`](emojivoto/) | ||
## Running | ||
|
||
A microservice application that allows users to vote for their favorite emoji, | ||
and tracks votes received on a leaderboard. May the best emoji win. | ||
### In Minikube | ||
|
||
Deploy the application to Minikube using the Linkerd2 service mesh. | ||
|
||
1. Install the `linkerd` CLI | ||
|
||
``` | ||
curl https://run.conduit.io/install | sh | ||
``` | ||
|
||
2. Install Linkerd2 | ||
|
||
``` | ||
linkerd install | kubectl apply -f - | ||
``` | ||
|
||
3. View the dashboard! | ||
|
||
``` | ||
linkerd dashboard | ||
``` | ||
|
||
4. Inject, Deploy, and Enjoy | ||
|
||
``` | ||
linkerd inject emojivoto.yml | kubectl apply -f - | ||
``` | ||
|
||
5. 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 :doughnut: 15% of the time. | ||
- It votes for :poop: 20% of the time. | ||
- When not voting for :doughnut: or :poop:, 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 | ||
```bash | ||
docker login | ||
docker push buoyantio/emojivoto-svc-base:v4 | ||
docker push buoyantio/emojivoto-emoji-svc:v4 | ||
docker push buoyantio/emojivoto-voting-svc:v4 | ||
docker push buoyantio/emojivoto-web:v4 | ||
``` | ||
6. 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 | ||
## Lifecycle | ||
# if you ran yarn webpack | ||
export INDEX_BUNDLE=emojivoto-web/webapp/dist/index_bundle.js | ||
* [`lifecycle/`](lifecycle/) | ||
# if you ran yarn webpack-dev-server | ||
export WEBPACK_DEV_SERVER=http://localhost:8083 | ||
Production testing the proxy's discovery & caching. | ||
# start the webserver | ||
go run emojivoto-web/cmd/server.go | ||
``` | ||
|
||
[conduit-logo]: https://user-images.githubusercontent.com/9226/33585569-c620a100-d919-11e7-83b6-a78f6e2683ec.png | ||
[Optional] Start the vote bot for automatic traffic generation. | ||
``` | ||
export WEB_HOST=localhost:8080 | ||
go run emojivoto-web/cmd/vote-bot/main.go | ||
``` |
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
emojivoto/emojivoto-emoji-svc/cmd/server.go → emojivoto-emoji-svc/cmd/server.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
emojivoto/emojivoto-voting-svc/cmd/server.go → emojivoto-voting-svc/cmd/server.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.