kuma-counter-demo

module
v0.0.0-...-9f766e2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2024 License: Apache-2.0

README

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

Directories

Path Synopsis
app
pkg
api
Package api provides primitives to interact with the openapi HTTP API.
Package api provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL