Explore Kuma with the Universal demo app

To start learning how Kuma works, you can download and run a simple demo application that consists of two services:

  • demo-app: web application that lets you increment a numeric counter
  • redis: data store for the counter

This guide also introduces some of the tools Kuma provides to help you control and monitor traffic, track resource status, and more.

The demo-app service 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) where the Redis instance is running. This name is displayed in the browser.

The zone key is purely static and arbitrary. Different zone values for different Redis instances let you keep track of which Redis instance stores the counter if you manage routes across different zones, clusters, and clouds.

Prerequisites

To explore traffic metrics with the demo app, you also need to set up Prometheus. See the traffic metrics policy documentation.

Set up

  1. Run redis as a daemon on port 26379 and set a default zone name:

    1. redis-server --port 26379 --daemonize yes
    2. redis-cli -p 26379 set zone local
  2. Install and start demo-app on the default port 5000:

    1. npm install --prefix=app/
    2. npm start --prefix=app/

Generate tokens

Create a token for Redis and a token for the app (all valid for 30 days):

  1. kumactl generate dataplane-token --tag kuma.io/service=redis --valid-for=720h > kuma-token-redis
  2. kumactl generate dataplane-token --tag kuma.io/service=app --valid-for=720h > kuma-token-app

This action requires authentication unless executed against a control-plane running on localhost. If kuma-cp is running inside docker container please see docker authentication docs .

Create a data plane proxy for each service

For Redis:

  1. kuma-dp run \
  2. --cp-address=https://localhost:5678/ \
  3. --dns-enabled=false \
  4. --dataplane-token-file=kuma-token-redis \
  5. --dataplane="
  6. type: Dataplane
  7. mesh: default
  8. name: redis
  9. networking:
  10. address: 127.0.0.1
  11. inbound:
  12. - port: 16379
  13. servicePort: 26379
  14. serviceAddress: 127.0.0.1
  15. tags:
  16. kuma.io/service: redis
  17. kuma.io/protocol: tcp
  18. admin:
  19. port: 9901"

And for the demo app:

  1. kuma-dp run \
  2. --cp-address=https://localhost:5678/ \
  3. --dns-enabled=false \
  4. --dataplane-token-file=kuma-token-app \
  5. --dataplane="
  6. type: Dataplane
  7. mesh: default
  8. name: app
  9. networking:
  10. address: 127.0.0.1
  11. outbound:
  12. - port: 6379
  13. tags:
  14. kuma.io/service: redis
  15. inbound:
  16. - port: 15000
  17. servicePort: 5000
  18. serviceAddress: 127.0.0.1
  19. tags:
  20. kuma.io/service: app
  21. kuma.io/protocol: http
  22. admin:
  23. port: 9902"

Run

Navigate to 127.0.0.1:5000 and increment the counter.

Explore the mesh

You can view the sidecar proxies that are connected to the Kuma control plane:

Kuma ships with a read-only GUI that you can use to retrieve Kuma resources. By default the GUI listens on the API port and defaults to :5681/gui.

You can navigate to 127.0.0.1:5681/meshes/default/dataplanes to see the connected dataplanes.

Kuma ships with a read-only HTTP API that you can use to retrieve Kuma resources.

By default the HTTP API listens on port 5681.

Navigate to 127.0.0.1:5681/meshes/default/dataplanes to see the connected dataplanes.

You can use the kumactl CLI to perform read-only operations on Kuma resources. The kumactl binary is a client to the Kuma HTTP API, you will need to first port-forward the API service with:

Run kumactl, for example:

  1. kumactl get dataplanes
  2. # MESH NAME TAGS
  3. # default kuma-demo-app-68758d8d5d-dddvg.kuma-demo app=kuma-demo-demo-app env=prod pod-template-hash=68758d8d5d protocol=http service=demo-app_kuma-demo_svc_5000 version=v8
  4. # default redis-master-657c58c859-5wkb4.kuma-demo app=redis pod-template-hash=657c58c859 protocol=tcp role=master service=redis_kuma-demo_svc_6379 tier=backend

You can configure kumactl to point to any zone kuma-cp instance by running:

  1. kumactl config control-planes add --name=XYZ --address=http://{address-to-kuma}:5681

Enable Mutual TLS and Traffic Permissions

By default the network is unsecure and not encrypted. We can change this with Kuma by enabling the Mutual TLS policy to provision a dynamic Certificate Authority (CA) on the default Mesh resource that will automatically assign TLS certificates to our services (more specifically to the injected dataplane proxies running alongside the services).

We can enable Mutual TLS with a builtin CA backend by executing:

  1. cat <<EOF | kumactl apply -f -
  2. type: Mesh
  3. name: default
  4. mtls:
  5. enabledBackend: ca-1
  6. backends:
  7. - name: ca-1
  8. type: builtin
  9. EOF

Once Mutual TLS has been enabled, Kuma will not allow traffic to flow freely across our services unless we explicitly have a Traffic Permission policy that describes what services can be consumed by other services. By default, a very permissive traffic permission is created.

For the sake of this demo we will delete it:

  1. kumactl delete traffic-permission allow-all-default

You can try to make requests to the demo application at 127.0.0.1:5000/ and you will notice that they will not work.

Now let’s add back the default traffic permission:

  1. cat <<EOF | kumactl apply -f -
  2. type: TrafficPermission
  3. name: allow-all-default
  4. mesh: default
  5. sources:
  6. - match:
  7. kuma.io/service: '*'
  8. destinations:
  9. - match:
  10. kuma.io/service: '*'
  11. EOF

By doing so every request we now make on our demo application at 127.0.0.1:5000/ is not only working again, but it is automatically encrypted and secure.

As usual, you can visualize the Mutual TLS configuration and the Traffic Permission policies we have just applied via the GUI, the HTTP API or kumactl.

Explore Traffic Metrics

One of the most important policies that Kuma provides out of the box is Traffic Metrics.

With Traffic Metrics we can leverage Prometheus and Grafana to provide powerful dashboards that visualize the overall traffic activity of our application and the status of the service mesh.

  1. cat <<EOF | kumactl apply -f -
  2. type: Mesh
  3. name: default
  4. mtls:
  5. enabledBackend: ca-1
  6. backends:
  7. - name: ca-1
  8. type: builtin
  9. metrics:
  10. enabledBackend: prometheus-1
  11. backends:
  12. - name: prometheus-1
  13. type: prometheus
  14. conf:
  15. skipMTLS: true
  16. EOF

This will enable the prometheus metrics backend on the default Mesh and automatically collect metrics for all of our traffic.

Increment the counter to generate traffic, and access the dashboard at 127.0.0.1:3000 with default credentials for both the username (admin) and the password (admin).

Kuma automatically installs three dashboard that are ready to use:

  • Kuma Mesh: to visualize the status of the overall Mesh.
  • Kuma Dataplane: to visualize metrics for a single individual dataplane.
  • Kuma Service to Service: to visualize traffic metrics for our services.

You can now explore the dashboards and see the metrics being populated over time.

Next steps

  • Explore the Policies available to govern and orchestrate your service traffic.
  • Read the full documentation to learn about all the capabilities of Kuma.
  • Chat with us at the official Kuma Slack for questions or feedback.