• Stars
    star
    195
  • Rank 199,374 (Top 4 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Example application to help demonstrate the Linkerd service mesh

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
  2. Install Linkerd2

    linkerd install | kubectl apply -f -
  3. View the dashboard!

    linkerd dashboard
  4. Inject, Deploy, and Enjoy

    kubectl kustomize kustomize/deployment | \
        linkerd inject - | \
        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.

Via URL

To deploy standalone to an existing cluster:

kubectl apply -k github.com/BuoyantIO/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/[email protected]
go install google.golang.org/grpc/cmd/[email protected]

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

make build

Releasing a new version

To build and push multi-arch docker images:

  1. Update the tag name in common.mk

  2. Create the Buildx builder instance

    docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
    docker buildx create --name=multiarch-builder --driver=docker-container --use
    docker buildx inspect multiarch-builder --bootstrap
  3. Build & push the multi-arch docker images to hub.docker.com

    docker login
    make multi-arch
  4. Update:

    • docker-compose.yml
    • kustomize/deployment/emoji.yml
    • kustomize/deployment/vote-bot.yml
    • kustomize/deployment/voting.yml
    • kustomize/deployment/web.yml
  5. Distribute to the Linkerd website repo

    kubectl kustomize kustomize/deployment  > ../website/run.linkerd.io/public/emojivoto.yml
    kubectl kustomize kustomize/daemonset   > ../website/run.linkerd.io/public/emojivoto-daemonset.yml
    kubectl kustomize kustomize/statefulset > ../website/run.linkerd.io/public/emojivoto-statefulset.yml

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

[In a separate terminal window] Start the emoji service

GRPC_PORT=8082 go run emojivoto-emoji-svc/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

Testing Linkerd Service Profiles

Service Profiles are a feature of Linkerd that provide per-route functionality such as telemetry, timeouts, and retries. The Emojivoto application is designed to showcase Service Profiles by following the instructions below.

Generate the ServiceProfile definitions from the .proto files

The emoji and voting services are gRPC applications which have Protocol Buffers (protobuf) definition files. These .proto files can be used as input to the linkerd profile command in order to create the ServiceProfile definition yaml files. The Linkerd Service Profile documentation outlines the steps necessary to create the yaml files, and these are the commands you can use from the root of this repository:

linkerd profile --proto proto/Emoji.proto emoji-svc -n emojivoto
linkerd profile --proto proto/Voting.proto voting-svc -n emojivoto

Each of these commands will output yaml that you can write to a file or pipe directly to kubectl apply. For example:

  • To write to a file:
linkerd profile --proto proto/Emoji.proto emoji-svc -n emojivoto > emoji
-sp.yaml
  • To apply directly:
linkerd profile --proto proto/Voting.proto voting-svc -n emojivoto | \
kubectl apply -f -

Generate the ServiceProfile definition for the Web deployment

The web-svc deployment of emojivoto is a React application that is hosted by a Go server. We can use linkerd profile auto creation to generate the ServiceProfile resource for the web-svc with this command:

linkerd profile -n emojivoto web-svc --tap deploy/web --tap-duration 10s | \
   kubectl apply -f -

Now that the service profiles are generated for all the services, you can observe the per-route metrics for each service on the Linkerd Dashboard or with the linkerd routes command

linkerd -n emojivoto routes deploy/web-svc --to svc/emoji-svc

License

Copyright 2020 Buoyant, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use these files except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

slow_cooker

A load tester focused on lifecycle issues and long-running tests
Go
323
star
2

strest-grpc

A load tester for stress testing grpc intermediaries.
Go
89
star
3

service-mesh-academy

Sources used for the Buoyant Service Mesh Academy, for your entertainment and knowledge, and as a base for getting things done.
Shell
67
star
4

demosh

Run code in Markdown files or shell scripts very interactively, to allow more engaging demos.
Python
36
star
5

bb

A tool to simulate many of the typical scenarios of cloud-native microservices.
Go
26
star
6

mTLS-workshop

Demo notes & scripts for Buoyant's mTLS workshop.
Shell
19
star
7

booksapp

Sample distributed Ruby app using Sinatra, ActiveRecord, and ActiveResource.
Ruby
13
star
8

faces-demo

A microservices application that shows a grid of cells, each of which should show a grinning face on a light blue background. All about showing how microservices applications work, how they fail, and how you can work with them.
Go
13
star
9

linkerd-workshops

Content for Linkerd workshops
Shell
12
star
10

linkerd-buoyant

Linkerd Buoyant releases
9
star
11

http-max-rps

A tool for finding the max RPS of an HTTP server or intermediary.
Go
9
star
12

cert-manager-workshop

Shell
9
star
13

real-world-argo-linkerd

Shell
9
star
14

flossy

a tool for testing standard compliance of HTTP proxies
Rust
7
star
15

gateway-api-workshop

Shell
6
star
16

kubectl

Kubectl in a scratch Docker image.
Dockerfile
4
star
17

debian-32-bit

Debian multiarch 32-bit/64-bit image with OpenJDK 8
2
star
18

byte-channel-rs

A Future-aware channel for buffered bytes
Rust
2
star
19

fauxmetheus

Serves fake Prometheus metrics which simulate a Linkerd cluster
Go
2
star
20

gitops_examples

1
star
21

test-futures-rs

Utilities for testing futures-rs implementations
Rust
1
star
22

linkerd-azure-marketplace-item

Contains Linkerd's Azure marketplace item.
Smarty
1
star
23

gitops-faces

1
star