Skip to content

Latest commit

 

History

History
65 lines (39 loc) · 3.21 KB

README.md

File metadata and controls

65 lines (39 loc) · 3.21 KB

Kuma Counter Demo

License Slack Twitter

Welcome to a sample application that demonstrates the Kuma service mesh in action. Kuma is designed to work across Kubernetes and VMs environments, with support for multi-zone deployments across many different clusters, data centers, and clouds.

To learn more about Kuma, see the Kuma docs.

Kuma is a CNCF Sandbox project.

Introduction

The application consists of two services:

  • A demo-app service that presents a web application that allows us to increment a numeric counter
  • A redis service that stores the counter

kuma-counter-demo

The demo-app service presents a browser interface that listens on port 5000. When it starts, it expects to find a zone key in Redis that specifies the name of the datacenter (or cluster) that the current redis instance belongs to. This name is then displayed in the demo-app GUI.

The zone key is purely static and arbitrary, but by having different zone values across different redis instances, we know at any given time from which Redis instance we are fetching/incrementing our counter when we route across a distributed environment across many zones, clusters and clouds.

Run the application

To run the kuma-counter-demo follow one of these guides:

Environment Variables

We can configure the following environment variables when running demo-app:

  • REDIS_HOST: Determines the hostname to use when connecting to Redis. Default is 127.0.0.1.
  • REDIS_PORT: Determines the port to use when connecting to Redis. Default is 6379.
  • APP_VERSION: Lets you change the version number displayed in the main page of demo-app. Default is 1.0.
  • APP_COLOR: Lets you change background color of the demo-app main page. Default is #efefef.

The APP_VERSION and APP_COLOR environment variables are handy when we want to create different versions of demo-app and get immediate visual feedback when routing across them.

Modifying responses

Adding delay to response

To add delay to response you need to set header x-set-response-delay-ms. Example:

curl localhost:5001/increment -XPOST -H "x-set-response-delay-ms: 5000"

Enforcing response status code

To enforce response status code you need to set header x-set-response-status-code. Example:

curl localhost:5001/increment -XPOST -H "x-set-response-status-code: 503"