Add the key/value store to the mesh

TL;DR

Issue a workload-bound data plane token, install the transparent proxy, and start kuma-dp beside the workload with a Dataplane resource describing its ports. The control plane generates the MeshService from the kuma.io/workload label.

Prerequisites

This page is part of the Get started with Kong Mesh on Universal series.

Complete the previous page, Set up the Kong Mesh control plane before completing this page.

This tutorial uses kongctl to manage Konnect resources programmatically. We recommend keeping kongctl up to date with the latest version (1.29.0).

  1. Install kongctl from developer.konghq.com/kongctl.
  2. Verify the installation:

    kongctl version

Issue a data plane token

A Universal proxy proves who it is with a data plane token. Bind it to the proxy’s name and to its workload:

kongctl create mesh dataplane-token \
  --control-plane-url "$KONG_MESH_CP" \
  --control-plane-token "$KONG_MESH_ADMIN_TOKEN" \
  --name kv \
  --workload kv \
  --valid-for 24h > "$KONG_MESH_DEMO_DIR/token-kv"

Start the container

  1. Start the container for the kv service:

    docker run \
      --detach \
      --name kong-mesh-demo-kv \
      --hostname kv \
      --network kong-mesh-demo \
      --ip 172.18.78.2 \
      --volume "$KONG_MESH_DEMO_DIR:/demo" \
      ghcr.io/kumahq/kuma-counter-demo:debian-slim
  2. Check that the store is listening on port 5050:

    docker logs kong-mesh-demo-kv

    You should get the following response:

    time=2025-03-14T12:17:34.630Z level=INFO ... msg="server running" addr=:5050

Install the sidecar binaries

Run the setup script created in the install step inside the container:

docker exec kong-mesh-demo-kv sh /demo/setup-sidecar.sh

Set the zone name

Set the zone name that the demo app will need:

docker exec kong-mesh-demo-kv \
  curl -s localhost:5050/api/key-value/zone \
    --header 'Content-Type: application/json' \
    --data '{"value":"local-demo-zone"}'

Install the transparent proxy

kumactl install transparent-proxy writes the iptables rules that redirect the container’s traffic through the sidecar. It needs root and the NET_ADMIN capability.

Run this command only inside the container. It redirects all of the host’s traffic to a data plane proxy, so running it on your own machine or a VM without one can cut off its network access.

Run the following command:

docker exec --privileged kong-mesh-demo-kv \
  kumactl install transparent-proxy \
    --config /demo/transparent-proxy.yaml

The last line of the output should be:

# transparent proxy setup completed successfully. You can now run kuma-dp with the transparent-proxy feature enabled

Start the sidecar

Run kuma-dp in the same container, as the kuma-dp user the iptables rules exclude, pointing it at the template created in the install step:

docker exec --detach kong-mesh-demo-kv sh -c '
  runuser -u kuma-dp -- kuma-dp run \
    --cp-address https://control-plane:5678 \
    --skip-verify \
    --dataplane-file /demo/dataplane.yaml \
    --dataplane-var name=kv \
    --dataplane-var address=172.18.78.2 \
    --dataplane-var port=5050 \
    --dataplane-token-file /demo/token-kv \
    --transparent-proxy-config /demo/transparent-proxy.yaml \
    > /demo/logs-kv.log 2>&1'

--skip-verify skips TLS verification of the control plane certificate. It is here because the demo control plane uses a self-signed certificate. Never use it outside a demo. Give kuma-dp the CA with --ca-cert-file instead.

In this example:

  • --dataplane-file applies the Dataplane as the proxy starts
  • The three --dataplane-var flags fill the template’s placeholders
  • --transparent-proxy-config turns on transparent proxying for this proxy and tells the control plane how the rules are set up
  • The sidecar’s output goes to $KONG_MESH_DEMO_DIR/logs-kv.log.

Check that the sidecar is connected

  1. Check that the kv data plane appears in the control plane:
    kongctl get mesh dataplanes \
      --control-plane-url "$KONG_MESH_CP" \
      --control-plane-token "$KONG_MESH_ADMIN_TOKEN"
  2. Check that the kv data plane is online:

    kongctl inspect mesh dataplanes \
      --control-plane-url "$KONG_MESH_CP" \
      --control-plane-token "$KONG_MESH_ADMIN_TOKEN"

    If kv doesn’t appear, check $KONG_MESH_DEMO_DIR/logs-kv.log for the reason.

Inspect the generated MeshService

The control plane generates a MeshService from the kuma.io/workload: kv label on the Dataplane, with one port per inbound.

  1. Check that the MeshService was created:

    kongctl get mesh meshservices \
      --control-plane-url "$KONG_MESH_CP" \
      --control-plane-token "$KONG_MESH_ADMIN_TOKEN"
  2. Check the generated configuration:

    kongctl get mesh meshservices kv -o yaml \
      --control-plane-url "$KONG_MESH_CP" \
      --control-plane-token "$KONG_MESH_ADMIN_TOKEN"

The selector matches on the workload label, the port carries the protocol you set on the inbound, and the status reports the VIP and the kv.svc.mesh.local hostname the demo app will reach it on.

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!