Connect a Universal zone to Konnect with the API

Incompatible with
on-prem
Related Documentation
Minimum Version
Kong Mesh - 3.0
Previous Versions of this page
TL;DR

Create a new global control plane running v3, deploy a 3.x zone control plane with its Konnect credentials, and verify that the zone connects.

Prerequisites

If you don’t have a Konnect account, you can get started quickly with our onboarding wizard.

  1. The following Konnect items are required to complete this tutorial:
    • Personal access token (PAT): Create a new personal access token by opening the Konnect PAT page and selecting Generate Token.
  2. Set the personal access token as an environment variable:

    export KONNECT_TOKEN='YOUR KONNECT TOKEN'

A supported VM or bare-metal host.

This guide creates a Konnect-managed global control plane and connects a Universal (VM or bare-metal) zone.

Create a global control plane in Konnect

  1. Set the region where you will create the global control plane:

    export KONNECT_REGION='us'
  2. Create a Kong Mesh v3 control plane in Konnect and save its ID to your environment:

    CONTROL_PLANE_ID=$(curl -X POST "https://$KONNECT_REGION.api.konghq.com/v1/mesh/control-planes" \
         --no-progress-meter --fail-with-body  \
         -H "Authorization: Bearer $KONNECT_TOKEN"\
         -H "Content-Type: application/json" \
         --json '{
           "name": "example-cp",
           "version": "v3"
         }' | jq -r ".id"
    )

Give the zone credentials to connect

The zone uses a system account access token with the Connector role on this control plane.

  1. Create a system account and save its id as ACCOUNT_ID:

    ACCOUNT_ID=$(curl -X POST "https://global.api.konghq.com/v3/system-accounts" \
         --no-progress-meter --fail-with-body  \
         -H "Authorization: Bearer $KONNECT_TOKEN"\
         -H "Content-Type: application/json" \
         --json '{
           "name": "mesh-zone-1",
           "description": "Connect zone-1",
           "konnect_managed": false
         }' | jq -r ".id"
    )
  2. Assign the account the Connector role on the control plane:

    curl -X POST "https://global.api.konghq.com/v3/system-accounts/$ACCOUNT_ID/assigned-roles" \
         --no-progress-meter --fail-with-body  \
         -H "Authorization: Bearer $KONNECT_TOKEN"\
         -H "Content-Type: application/json" \
         --json '{
           "role_name": "Connector",
           "entity_type_name": "Mesh Control Planes",
           "entity_id": "'$CONTROL_PLANE_ID'",
           "entity_region": "'$KONNECT_REGION'"
         }'
  3. Set the token to expire in 30 days. Change the number of days if your organization’s token policy requires a shorter lifetime:

    export TOKEN_EXPIRES_AT=$(jq -nr 'now + 30*24*60*60 | todate')
  4. Create the token and save the returned token as CONTROL_PLANE_TOKEN:

    CONTROL_PLANE_TOKEN=$(curl -X POST "https://global.api.konghq.com/v3/system-accounts/$ACCOUNT_ID/access-tokens" \
         --no-progress-meter --fail-with-body  \
         -H "Authorization: Bearer $KONNECT_TOKEN"\
         -H "Content-Type: application/json" \
         --json '{
           "name": "zone-1",
           "expires_at": "'$TOKEN_EXPIRES_AT'"
         }' | jq -r ".token"
    )

Deploy the zone control plane

  1. Set the KDS address for the same region as the global control plane, and create a working directory:

    export CONTROL_PLANE_URL="grpcs://$KONNECT_REGION.mesh.sync.konghq.com:443"
    export MESH_INSTALL_DIR="$PWD/kong-mesh-zone"
    mkdir -p "$MESH_INSTALL_DIR"
    cd "$MESH_INSTALL_DIR"
  2. Download and run the installer:

    curl --fail -L https://developer.konghq.com/mesh/installer.sh | VERSION="3.0.0" sh
  3. Write the zone token to a file:

    printf '%s' "$CONTROL_PLANE_TOKEN" > cp-token
  4. Create config.yaml:

    cat <<EOF > config.yaml
    environment: universal
    mode: zone
    store:
      type: memory
    multizone:
      zone:
        name: zone-1
        globalAddress: $CONTROL_PLANE_URL
    kmesh:
      multizone:
        zone:
          konnect:
            cpId: $CONTROL_PLANE_ID
    EOF

    Use store.type: memory for testing purposes only. In a production environment, use PostgreSQL and plan persistence and availability. For more information, see the Universal control plane reference.

  5. Start the control plane in the background and write its output to kuma-cp.log:

    KUMA_MULTIZONE_ZONE_KDS_AUTH_TOKEN_PATH="$MESH_INSTALL_DIR/cp-token" \
      nohup "$MESH_INSTALL_DIR/kong-mesh-3.0.0/bin/kuma-cp" run --config-file config.yaml \
      > kuma-cp.log 2>&1 &
    echo $! > kuma-cp.pid
  6. Wait for the control plane to report that it’s ready:

    curl --fail --silent --retry 30 --retry-delay 2 --retry-connrefused http://localhost:5680/ready

    If the command fails, check kuma-cp.log for the startup error.

Validate

Confirm the zone is connected to your global control plane:

kongctl inspect mesh zones \
  --control-plane-id "$CONTROL_PLANE_ID" --region "$KONNECT_REGION" \
  --pat "$KONNECT_TOKEN"

The zone should report an Online status:

NAME    STATUS
zone-1  Online

If a zone is missing or not Online, check:

  • The zone’s control plane logs
  • Outbound access to the KDS address
  • The control plane ID
  • The system account’s Connector role and token

Cleanup

Stop the control plane this guide started:

kill "$(cat "$MESH_INSTALL_DIR/kuma-cp.pid")"

Leave the zone working directory and delete it:

cd "$(dirname "$MESH_INSTALL_DIR")"
rm -rf "$MESH_INSTALL_DIR"

Delete the example-cp control plane. This also removes its mesh configuration:

curl --fail-with-body -sS -X DELETE \
  "https://$KONNECT_REGION.api.konghq.com/v1/mesh/control-planes/$CONTROL_PLANE_ID" \
  -H "Authorization: Bearer $KONNECT_TOKEN"

Delete the mesh-zone-1 system account:

curl --fail-with-body -sS -X DELETE \
  "https://global.api.konghq.com/v3/system-accounts/$ACCOUNT_ID" \
  -H "Authorization: Bearer $KONNECT_TOKEN"

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!