Giter Club home page Giter Club logo

cloudbowl-microservice-game's Introduction

Cloud Bowl

A game where microservices battle each other in a giant real-time bowl.

Run Locally:

  1. Make sure you have docker installed and running
  2. Start Kafka
    ./sbt "runMain apps.dev.KafkaApp"
    
  3. Start the sample service
    (cd samples/scala-play; ./sbt run)
    
  4. Start the Battle
    ./sbt "runMain apps.Battle"
    
  5. Start the apps.dev Kafka event viewer
    ./sbt "runMain apps.dev.KafkaConsumerApp"
    
  6. Start the apps.dev Kafka event producer
    ./sbt "runMain apps.dev.KafkaProducerApp"
    
    You can send commands like
    ARENA/create
    ARENA/unlist
    ARENA/playerjoin
    ARENA/playerfill/NUM
    ARENA/playerleave/ID
    ARENA/viewerjoin
    ARENA/scoresreset
    
  7. Start the Viewer web app
    ./sbt run
    
    Check out the foo arena: http://localhost:9000/foo

Web UI Notes:

Pause the Arena refresh:

document.body.dataset.paused = true;

Run on Google Cloud

  1. Create GKE Cluster with Cloud Run

    gcloud config set core/project YOUR_PROJECT
    
    gcloud services enable compute.googleapis.com container.googleapis.comcontainer.googleapis.com containerregistry.googleapis.com cloudbuild.googleapis.com
    
    gcloud config set compute/region us-central1
    gcloud config set container/cluster cloudbowl
    
    gcloud container clusters create \
      --region=$(gcloud config get-value compute/region) \
      --addons=HorizontalPodAutoscaling,HttpLoadBalancing,CloudRun \
      --machine-type=n1-standard-4 \
      --enable-stackdriver-kubernetes \
      --enable-ip-alias \
      --enable-autoscaling --num-nodes=1 --min-nodes=0 --max-nodes=20 \
      --release-channel=stable \
      --scopes cloud-platform \
      $(gcloud config get-value container/cluster)
    
  2. Install Strimzi Kafka Operator

    kubectl create namespace kafka
    curl -L https://github.com/strimzi/strimzi-kafka-operator/releases/download/0.20.0/strimzi-cluster-operator-0.20.0.yaml \
      | sed 's/namespace: .*/namespace: kafka/' \
      | kubectl apply -f - -n kafka
    
  3. Setup the Kafka Cluster

    kubectl apply -n kafka -f .infra/kafka.yaml
    kubectl wait -n kafka kafka/cloudbowl --for=condition=Ready --timeout=300s
    
  4. Get your IP Address:

    export IP_ADDRESS=$(kubectl get svc istio-ingress -n gke-system -o 'jsonpath={.status.loadBalancer.ingress[0].ip}')
    echo $IP_ADDRESS
    
  5. Create a ConfigMap named cloudbowl-config:

    export APPLICATION_SECRET=$(head -c 32 /dev/urandom | base64)
    export ADMIN_PASSWORD=PICK_A_PASSWORD # Used for creating / updating arenas
    cat <<EOF | kubectl apply -f -
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: cloudbowl-config
    data:
      WEBJARS_USE_CDN: 'true'
      APPLICATION_SECRET: $APPLICATION_SECRET
      ADMIN_PASSWORD: $ADMIN_PASSWORD
    EOF
    
  6. Setup Cloud Build with a trigger on master, excluding samples/**, with Configuration Type set to Cloud Build configuration file, and substitution vars _CLOUDSDK_COMPUTE_REGION and _CLOUDSDK_CONTAINER_CLUSTER. Running the trigger will create the Kafka topics, deploy the battle service, and the web app.

  7. Once the service is deployed, setup the domain name:

    export IP_ADDRESS=$(kubectl get svc istio-ingress -n gke-system -o 'jsonpath={.status.loadBalancer.ingress[0].ip}')
    echo "IP_ADDRESS=$IP_ADDRESS"
    
    gcloud beta run domain-mappings create --service cloudbowl-web --domain $IP_ADDRESS.nip.io --platform=gke --project=$(gcloud config get-value core/project) \
      --cluster=$(gcloud config get-value container/cluster) --cluster-location=$(gcloud config get-value compute/region)
    gcloud compute addresses create cloudbowl-ip --addresses=$IP_ADDRESS --region=$(gcloud config get-value compute/region)
    
  8. Turn on TLS support:

    kubectl patch cm config-domainmapping -n knative-serving -p '{"data":{"autoTLS":"Enabled"}}'
    kubectl get kcert
    

Troubleshooting

# Pick a topic:
export TOPIC=viewer-ping
export TOPIC=players-refresh
export TOPIC=arena-update

# Describe a topic:
kubectl -n kafka run kafka-consumer -ti --image=strimzi/kafka:0.17.0-kafka-2.4.0 --rm=true --restart=Never -- bin/kafka-topics.sh --describe --bootstrap-server cloudbowl-kafka-bootstrap.kafka:9092 --topic $TOPIC

# Consume messages on a topic:
kubectl -n kafka run kafka-consumer -ti --image=strimzi/kafka:0.17.0-kafka-2.4.0 --rm=true --restart=Never -- bin/kafka-console-consumer.sh --bootstrap-server cloudbowl-kafka-bootstrap.kafka:9092 --topic $TOPIC --from-beginning --property print.key=true --property key.separator=":"

cloudbowl-microservice-game's People

Contributors

ahmetb avatar dependabot[bot] avatar dumptruckman avatar hostirosti avatar jamesward avatar joshlong avatar krumpff-g avatar mco-gh avatar tarczynskitomek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloudbowl-microservice-game's Issues

Show position of current user on the matrix

It would be nice to be able to track chosen user on the matrix p. ex. with a frame of some bright color. This would enable observation of users when there are so many of them that the avatar itself is difficult to find.

Security Policy violation Binary Artifacts

This issue was automatically created by Allstar.

Security Policy Violation
Project is out of compliance with Binary Artifacts policy: binaries present in source code

Rule Description
Binary Artifacts are an increased security risk in your repository. Binary artifacts cannot be reviewed, allowing the introduction of possibly obsolete or maliciously subverted executables. For more information see the Security Scorecards Documentation for Binary Artifacts.

Remediation Steps
To remediate, remove the generated executable artifacts from the repository.

Artifacts Found

  • samples/java-quarkus/.mvn/wrapper/maven-wrapper.jar
  • samples/java-springboot/.mvn/wrapper/maven-wrapper.jar
  • samples/kotlin-quarkus/.mvn/wrapper/maven-wrapper.jar
  • samples/kotlin-springboot/.mvn/wrapper/maven-wrapper.jar
  • samples/scala-play/sbt-launch.jar
  • sbt-launch.jar

Additional Information
This policy is drawn from Security Scorecards, which is a tool that scores a project's adherence to security best practices. You may wish to run a Scorecards scan directly on this repository for more details.


Allstar has been installed on all Google managed GitHub orgs. Policies are gradually being rolled out and enforced by the GOSST and OSPO teams. Learn more at http://go/allstar

This issue will auto resolve when the policy is in compliance.

Issue created by Allstar. See https://github.com/ossf/allstar/ for more information. For questions specific to the repository, please contact the owner or maintainer.

Kinda-slow services result in errors

I thought services were supposed to have about 1sec to respond but if a service takes much longer than 200ms then it is classified as an error. This usually happens when a service is on the other side of the world than the arena runner.

wasHit Not Sent to Players

Iteration Currently (I think):

  1. Reset wasHit
  2. Send JSON to all Players
  3. Update arena state for each player, just changing wasHit to true if the player was hit

Because it's easier to know if a player wasHit than if they weren't hit.

Location Transparency

Is it possible to make location irrelevant? Ideally it wouldn't matter where a service is running. But that would mean making the request come from the same location as the service.

Run the arena runner in all regions, make the request from all regions, have some auto-selection with back-off for re-evaluation?

What does aggregation across all regions do to the tick?

Virtual Battles

Provide a way for anyone to participate in battles.

  • GitHub-based player database (players send PRs to be added)
  • Local dev instructions
  • Configurable battle icon (peach, snowball, etc)
  • Configurable battle restart interval
  • Battle sharding
  • Kafka in K8s
  • Front-end in K8s
  • More microservice examples
    • Go
    • Python
    • Node

Newer Version of Flask Causing issues

Hi,
The Python/Flask module is failing on Ln 9 of main.py

When I updated Flask to the latest version, it all started to work again.

Can the requirements.txt please be updated to include the latest Flask Version.

UI Improvements

  • Show loading indicator
  • If nothing loads in x seconds, say the arena is empty
  • Link to arena config (where applicable)

Redirect to https

Currently blocked on Cloud Run for Anthos bug where the forward headers do not correctly indicate the protocol as https when the request comes via https.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.