Connect a second zone

TL;DR
  1. Start a second Kubernetes cluster.
  2. Give the zone its own system account token with the Connector role on the global control plane.
  3. Install a zone control plane named zone2 with Helm, with the same meshes entry as zone1.
  4. Check that both zones are online and that zone2 received kong-air-mesh.

Prerequisites

This page is part of the Kong Mesh scenarios: the Kong Air journey series.

Complete the previous page, Observe mesh traffic in practice 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.28.4).

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

    kongctl version

Kong Air runs its services in more than one region. In this guide, you connect a second Kubernetes zone, zone2, to the same global control plane as zone1.

To learn more about what this guide does, read the following reference pages:

Start the zone2 cluster

  1. Save the kubectl context of zone1, so that later commands can target each zone:

    export ZONE1_CONTEXT=$(kubectl config current-context)
  2. Start a second minikube cluster on the same Docker network as zone1, so that the two zones can reach each other:

    export ZONE1_IP=$(minikube ip -p mesh-zone)
    minikube start -p mesh-zone-2 --driver=docker --network=mesh-zone --static-ip="${ZONE1_IP%.*}.3"
    export ZONE2_CONTEXT=mesh-zone-2

    On a shared network, minikube would give the new node the same IP address as the zone1 node, so --static-ip picks the next free address in the zone1 subnet. --driver=docker keeps minikube from falling back to a driver that doesn’t support --network.

Give zone2 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 ZONE2_ACCOUNT_ID:

    ZONE2_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-zone2",
           "description": "Connect zone2",
           "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/$ZONE2_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 ZONE2_CONTROL_PLANE_TOKEN:

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

Install the zone2 control plane

  1. Create the namespace for the zone control plane:

    kubectl --context "$ZONE2_CONTEXT" create namespace kong-mesh-system
  2. Store the system account token in the token key of a Kubernetes secret named cp-token:

    kubectl --context "$ZONE2_CONTEXT" create secret generic cp-token \
      -n kong-mesh-system \
      --from-literal=token="$ZONE2_CONTROL_PLANE_TOKEN"
  3. Create the Helm values file. It matches the values you used for zone1 in Install Kong Mesh and deploy Kong Air, except for the zone name:

    cat <<EOF > zone2-values.yaml
    kuma:
      controlPlane:
        mode: zone
        zone: zone2
        kdsGlobalAddress: $CONTROL_PLANE_URL
        konnect:
          cpId: $CONTROL_PLANE_ID
        zoneToken:
          secretName: cp-token
          key: token
        envVars:
          KUMA_DEFAULTS_RESTRICT_OUTBOUND: "false"
      meshes:
        - name: kong-air-mesh
          ingress:
            enabled: true
            service:
              type: NodePort
          egress:
            enabled: true
    EOF
  4. Install the Kong Mesh zone control plane in zone2 and wait for it to be ready:

    helm upgrade --install --kube-context "$ZONE2_CONTEXT" \
      --namespace kong-mesh-system \
      kong-mesh kong-mesh/kong-mesh -f zone2-values.yaml
    kubectl --context "$ZONE2_CONTEXT" wait -n kong-mesh-system --for=condition=ready pod \
      --selector=app=kong-mesh-control-plane --timeout=90s
  5. Switch back to the zone1 context:

    kubectl config use-context "$ZONE1_CONTEXT"

Validate

Confirm the zones are connected to your global control plane:

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

Each zone should report an Online status:

NAME    STATUS
zone1  Online
zone2  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

Then confirm that zone2 received kong-air-mesh from the global control plane:

kubectl --context "$ZONE2_CONTEXT" get meshes

The output lists kong-air-mesh.

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!