Skip to content

kumahq/kuma-counter-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

212 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Kuma Counter Demo

Run in Insomnia}

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 website.

Kuma is a CNCF Sandbox project.

Introduction

The application consists of the same app instantiated differently to simulate 2 services:

  • A demo-app service that presents a web application that allows us to increment a numeric counter
  • A kv service which simulates a database.
flowchart LR
browser

subgraph kuma-mesh
edge-gateway
demo-app(demo-app :5050)
kv(kv :5050)
end
edge-gateway --> demo-app
demo-app --> kv
browser --> edge-gateway
Loading

The demo-app service presents a browser interface that listens on port 5050.

You can set the zone key on the kv curl -v -XPOST -d '{"value":"zone-1"}' localhost:5050/api/key-value/zone -H 'content-type: application/json' where localhost:5050 is your kv service.

Run the application

Follow the getting-started on the Kuma docs.

Or you can play with skaffold on your already running k8s cluster:

make skaffold/dev

This will demo an entire stack on top of Kuma.

You can also just pick which demo you want with:

make demo/list

Which will return something like:

$ make demo/list
# Run the demo application without Kuma
kubectl apply -k kustomize/base
# Run the demo application with Kuma
kubectl apply -k kustomize/overlays/000-with-kuma
# Run the demo application with Kuma, mTLS and Mesh Traffic Permission
kubectl apply -k kustomize/overlays/001-with-mtls
# Run the demo application with Kuma, mTLS, Mesh Traffic Permission and a Gateway
kubectl apply -k kustomize/overlays/002-with-gateway

To apply these manifests directly, you should have a running k8s cluster and Kuma already installed.

helm install kuma kuma/kuma --create-namespace --namespace kuma-system

You can cleanup a demo by doing: kubectl delete -k k8s/overlays/002-with-gateway

Environment Variables

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

  • KV_URL: The address at which to contact the service.
  • APP_VERSION: Lets you change the version number displayed in the main page of demo-app and the header x-demo-app-version to all responses.

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

Debugging

To debug things we strongly recommend using: netshoot:

kubectl debug  demo-app-68784dc9d7-rjxgx -n kuma-demo -it --image=nicolaka/netshoot

Modifying responses

Adding delay to response

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

curl localhost:5050/api/counter -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:5050/api/counter -XPOST -H "x-set-response-status-code: 503"

Simulating failures with fault injection

To simulate random failures you need to set header x-failure-percentage with a value between 0 and 100. A value of 0 (or missing header) means no failures, while 100 means always fail. Example:

# 50% chance of failure
curl localhost:5050/api/counter -XPOST -H "x-failure-percentage: 50"

# Always fail
curl localhost:5050/api/version -H "x-failure-percentage: 100"

# No failures (same as not setting the header)
curl localhost:5050/api/version -H "x-failure-percentage: 0"

About

This is the counter demo for Kuma, that demonstrates the capabilities of the service mesh.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors