Connect a Kubernetes 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'

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

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

    kongctl version

You will need Helm, a package manager for Kubernetes.

This guide creates a Konnect-managed global control plane, connects a Kubernetes zone, and verifies that the zone is online.

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. Add the Kong Mesh Helm repository:

    helm repo add kong-mesh https://kong.github.io/kong-mesh-charts
    helm repo update
  3. Create the zone namespace:

    kubectl create namespace kong-mesh-system
  4. Store the zone token in a Secret:

    kubectl -n kong-mesh-system create secret generic cp-token \
      --from-literal=token="$CONTROL_PLANE_TOKEN"
  5. Create values.yaml:

    cat <<EOF > values.yaml
    kuma:
      controlPlane:
        mode: zone
        zone: zone-1
        kdsGlobalAddress: $CONTROL_PLANE_URL
        konnect:
          cpId: $CONTROL_PLANE_ID
        zoneToken:
          secretName: cp-token
          key: token
    EOF
  6. Install the zone control plane:

    helm upgrade --install kong-mesh kong-mesh/kong-mesh \
      --namespace kong-mesh-system --version "3.0.0" \
      --values values.yaml --wait --timeout 5m

    This single-zone test doesn’t need zone proxies; add mesh-scoped zone proxies when connecting zones or using MeshExternalService.

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

Delete the test namespace:

kubectl delete namespace kong-mesh-demo

Uninstall the zone release:

helm uninstall kong-mesh --namespace kong-mesh-system

Delete the zone namespace and the cp-token Secret in it:

kubectl delete namespace kong-mesh-system

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!