Emojivoto - A microservice application that allows users to vote for their favorite emoji

Overview

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

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

Requirements

  1. Set your GOPATH
   export GOPATH=/path/to/go
  1. Add your GOPATH/bin to the PATH
   export PATH=$PATH:$GOPATH/bin
  1. Install protobuf compiler: https://grpc.io/docs/protoc-installation/
  2. Install go packages
go get -u github.com/golang/protobuf/protoc-gen-go
go get google.golang.org/protobuf/reflect/[email protected]
go get google.golang.org/protobuf/runtime/[email protected]
  1. Install yarn: https://classic.yarnpkg.com/en/docs/install/

Building process

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

Set up proto files, build apps

make local

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.

You might also like...
A Kubernetes Operator, that helps DevOps team accelerate their journey into the cloud and K8s.
A Kubernetes Operator, that helps DevOps team accelerate their journey into the cloud and K8s.

A Kubernetes Operator, that helps DevOps team accelerate their journey into the cloud and K8s. OAM operator scaffolds all of the code required to create resources across various cloud provides, which includes both K8s and Non-K8s resources

Viewnode displays Kubernetes cluster nodes with their pods and containers.

viewnode The viewnode shows Kubernetes cluster nodes with their pods and containers. It is very useful when you need to monitor multiple resources suc

🔮 ✈️ to integrate OPA Gatekeeper's new ExternalData feature with cosign to determine whether the images are valid by verifying their signatures

cosign-gatekeeper-provider To integrate OPA Gatekeeper's new ExternalData feature with cosign to determine whether the images are valid by verifying i

A plugin for Hashicorp Vault to create ephemeral users and API tokens for Jenkins CI
A plugin for Hashicorp Vault to create ephemeral users and API tokens for Jenkins CI

vault-plugin-secrets-jenkins This is a backend plugin to be used with Hashicorp Vault. This plugin generates ephemeral Jenkins Users and API tokens. v

Linux provisioning scripts + application deployment tools. Suitable for self-hosting and hobby-scale application deployments.

Apollo Linux provisioning scripts + application deployment tools. Suitable for self-hosting and hobby-scale application deployments. Philosophy Linux-

Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications
Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications

Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations.

⚡️ A dev tool for microservice developers to run local applications and/or forward others from/to Kubernetes SSH or TCP
⚡️ A dev tool for microservice developers to run local applications and/or forward others from/to Kubernetes SSH or TCP

Your new microservice development environment friend. This CLI tool allows you to define a configuration to work with both local applications (Go, Nod

Service Discovery and Governance Center for Distributed and Microservice Architecture
Service Discovery and Governance Center for Distributed and Microservice Architecture

Polaris: Service Discovery and Governance English | 简体中文 README: Introduction Components Getting started Chat group Contribution Visit website to lear

Microservice we use to post reddit posts to a webhook

TypicalBot Reddit Webhook Poster Microservice we use to post reddit posts to a webhook. How to run The SHARED_API environment variable is to hook into

Owner
Kriil
Kriil
A Go based deployment tool that allows the users to deploy the web application on the server using SSH information and pem file.

A Go based deployment tool that allows the users to deploy the web application on the server using SSH information and pem file. This application is intend for non tecnhincal users they can just open the GUI and given the server details just deploy.

Jobin Jose 1 Oct 16, 2021
Enforcing per team quota (sum of used resources across all their namespaces) and delegating the per namespace quota to users.

Quota Operator Enforcing per team quota (sum of used resources across all their namespaces) and delegating the per namespace quota to users. Instructi

Snapp Cab Incubators 16 Nov 9, 2022
Openshift's hpessa-exporter allows users to export SMART information of local storage devices as Prometheus metrics, by using HPE Smart Storage Administrator tool

hpessa-exporter Overview Openshift's hpessa-exporter allows users to export SMART information of local storage devices as Prometheus metrics, by using

Shachar Sharon 0 Jan 17, 2022
Topology-tester - Application to easily test microservice topologies and distributed tracing including K8s and Istio

Topology Tester The Topology Tester app allows you to quickly build a dynamic mi

Bas van Beek 1 Jan 14, 2022
Solana Token Registry - a package that allows application to query for list of tokens

Please note: This repository is being rebuilt to accept the new volume of token additions and modifications. PR merges will be delayed. @solana/spl-to

Square and Compass 0 Jan 16, 2022
An experimental Go application that allows an SSH session to interact with the clipboard of the host machine and forward calls to open

Remote Development Manager An experimental Go application that allows an SSH session to interact with the clipboard of the host machine and forward ca

Blake Williams 29 Dec 27, 2022
Stackie enables developers to configure their local environment/toolchain with ease.

Stackie enables developers to configure their local environment/toolchain with ease. Made for Pulumi CLI, Google Cloud Platform (gcloud), and Amazon Web Services (aws-cli).

Bjerk AS 6 Sep 10, 2021
ControllerMesh is a solution that helps developers manage their controllers/operators better.

ControllerMesh ControllerMesh is a solution that helps developers manage their controllers/operators better. Key Features Canary update: the controlle

OpenKruise 36 Jan 6, 2023
Watchtower for Git: automatically keep local Git repositories up to date with their remotes

CrowsNest Watchtower for Git: automatically keep local Git repositories up to date with their remotes. Configuration Flags --run-once or -r: Normally

Simon 59 Oct 30, 2022
The GCP Enterprise Cloud Cost Optimiser, or gecco for short, helps teams optimise their cloud project costs.

gecco helps teams optimise their cloud resource costs. Locate abandoned, idle, and inefficiently configured resources quickly. gecco helps teams build

aeihr. 2 Jan 9, 2022