Categorygithub.com/kumahq/kuma-counter-demo
repository
2.0.0-rc9+incompatible
Repository: https://github.com/kumahq/kuma-counter-demo.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# README

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

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.

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.

K8s manifests

In the k8s folder you can access a simple manifests to run the workloads using: kubectl apply -f k8s/demo-app.yaml. There are then extra examples to play with Kuma.

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"

Developing

You'll only need mise.

make clean
make generate
make test
make build