Install Kong Mesh and deploy Kong Air

TL;DR
  1. Create a global control plane in Konnect.
  2. Create the kong-air-mesh mesh on the global control plane with kongctl.
  3. Install a zone control plane on Kubernetes with Helm and connect it to the global control plane as zone1.
  4. Deploy the Kong Air demo applications into a namespace with sidecar injection enabled.

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

The series runs each zone in its own minikube cluster, with the Docker driver. The zone2 cluster joins the Docker network of the zone1 cluster, so start zone1 with the following profile name:

minikube start -p mesh-zone --driver=docker

You will need Helm, a package manager for Kubernetes.

Every Kong Air scenario runs on the same foundation:

  • A kong-air-mesh mesh on a Konnect-hosted global control plane
  • One Kubernetes zone named zone1, connected to the global control plane
  • Three demo applications

In this guide, you build that foundation.

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

Create a working directory

Create a directory for the files that the series creates, such as Helm values files, and change to it. Run the commands of every guide in the series from this directory:

mkdir kong-air-scenarios && cd kong-air-scenarios

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": "kong-air-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-zone1",
           "description": "Connect zone1",
           "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": "zone1",
           "expires_at": "'$TOKEN_EXPIRES_AT'"
         }' | jq -r ".token"
    )

Create the mesh and connect a Kubernetes zone

The Kong Air zone control plane runs on Kubernetes and connects to the Konnect global control plane. You create the mesh on the global control plane with kongctl, then install the zone control plane with Helm.

  1. Create the kong-air-mesh mesh on the global control plane:

    kongctl apply mesh -f - --control-plane-id "$CONTROL_PLANE_ID" \
      --base-url "https://$KONNECT_REGION.api.konghq.com" --pat "$KONNECT_TOKEN" <<'EOF'
    type: Mesh
    name: kong-air-mesh
    EOF
  2. Export the Kuma Discovery Service (KDS) address that the zone connects to:

    export CONTROL_PLANE_URL="grpcs://$KONNECT_REGION.mesh.sync.konghq.com:443"
  3. Create the namespace for the zone control plane:

    kubectl create namespace kong-mesh-system
  4. Store the system account token in the token key of a Kubernetes secret named cp-token. The zone control plane uses this token to prove its identity when it joins the global control plane:

    kubectl create secret generic cp-token \
      -n kong-mesh-system \
      --from-literal=token="$CONTROL_PLANE_TOKEN"
  5. Create the Helm values file. The meshes entry deploys a zone ingress and a zone egress for kong-air-mesh:

    cat <<EOF > values.yaml
    kuma:
      controlPlane:
        mode: zone
        zone: zone1
        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

    The ingress Service uses the NodePort type, because a local cluster such as minikube doesn’t assign an address to a LoadBalancer Service. The zone control plane publishes the node IP and port in a MeshZoneAddress, so other zones can reach the ingress. On a cloud cluster, you can use a LoadBalancer Service instead.

    The zoneToken entry mounts the cp-token secret into the zone control plane as a file. The zone control plane reads the token on every KDS connection, so it picks up a rotated token without a restart.

    The values file sets KUMA_DEFAULTS_RESTRICT_OUTBOUND to false, so the Kong Air mesh starts open on purpose. With this setting, sidecars can reach destinations that you haven’t declared yet. Prepare the mesh for production turns restrictOutbound on, which is how a production mesh must run.

  6. Add the Kong Mesh Helm repository:

    helm repo add kong-mesh https://kong.github.io/kong-mesh-charts
    helm repo update
  7. Install the Kong Mesh zone control plane with your values file and wait for it to be ready:

    helm upgrade --install \
      --namespace kong-mesh-system \
      kong-mesh kong-mesh/kong-mesh -f values.yaml
    kubectl wait -n kong-mesh-system --for=condition=ready pod \
      --selector=app=kong-mesh-control-plane --timeout=90s
  8. Confirm that the zone joined the global control plane and received the mesh:

    kubectl get meshes

    The output lists kong-air-mesh after the global control plane sends the mesh to the zone over KDS. This confirms that the zone is connected.

Deploy Kong Air

  1. Deploy the Kong Air demo applications: passenger-portal, check-in-api, and flight-control:

    kubectl apply -f - <<'EOF'
    apiVersion: v1
    kind: Namespace
    metadata:
      name: kong-air-production
      labels:
        kuma.io/sidecar-injection: enabled
        kuma.io/mesh: kong-air-mesh
    ---
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: passenger-portal
      namespace: kong-air-production
    ---
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: check-in-api
      namespace: kong-air-production
    ---
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: flight-control
      namespace: kong-air-production
    ---
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: nginx-passthrough
      namespace: kong-air-production
    data:
      default.conf: |
        server {
            listen 8080;
            location / {
                add_header Content-Type text/plain;
                return 200 "$hostname\n";
            }
            location /health {
                add_header Content-Type text/plain;
                return 200 "ok\n";
            }
            location = /manifest.bin {
                root /tmp;
            }
        }
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: passenger-portal
      namespace: kong-air-production
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: passenger-portal
          version: v1
      template:
        metadata:
          labels:
            app: passenger-portal
            version: v1
        spec:
          serviceAccountName: passenger-portal
          containers:
            - name: passenger-portal
              image: nginx:alpine
              ports:
                - containerPort: 8080
              volumeMounts:
                - name: nginx-config
                  mountPath: /etc/nginx/conf.d
              readinessProbe:
                httpGet:
                  path: /health
                  port: 8080
                initialDelaySeconds: 5
                periodSeconds: 5
          volumes:
            - name: nginx-config
              configMap:
                name: nginx-passthrough
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: passenger-portal
      namespace: kong-air-production
    spec:
      selector:
        app: passenger-portal
      ports:
        - port: 8080
          targetPort: 8080
          name: http
          appProtocol: http
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: check-in-api
      namespace: kong-air-production
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: check-in-api
          version: v1
      template:
        metadata:
          labels:
            app: check-in-api
            version: v1
        spec:
          serviceAccountName: check-in-api
          containers:
            - name: check-in-api
              image: nginx:alpine
              ports:
                - containerPort: 8080
              volumeMounts:
                - name: nginx-config
                  mountPath: /etc/nginx/conf.d
              readinessProbe:
                httpGet:
                  path: /health
                  port: 8080
                initialDelaySeconds: 5
                periodSeconds: 5
          volumes:
            - name: nginx-config
              configMap:
                name: nginx-passthrough
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: check-in-api
      namespace: kong-air-production
    spec:
      selector:
        app: check-in-api
      ports:
        - port: 8080
          targetPort: 8080
          name: http
          appProtocol: http
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: flight-control
      namespace: kong-air-production
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: flight-control
          version: v1
      template:
        metadata:
          labels:
            app: flight-control
            version: v1
        spec:
          serviceAccountName: flight-control
          containers:
            - name: flight-control
              image: nginx:alpine
              ports:
                - containerPort: 8080
              volumeMounts:
                - name: nginx-config
                  mountPath: /etc/nginx/conf.d
              readinessProbe:
                httpGet:
                  path: /health
                  port: 8080
                initialDelaySeconds: 5
                periodSeconds: 5
          volumes:
            - name: nginx-config
              configMap:
                name: nginx-passthrough
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: flight-control
      namespace: kong-air-production
    spec:
      selector:
        app: flight-control
      ports:
        - port: 8080
          targetPort: 8080
          name: http
          appProtocol: http
    EOF

    Each application is an nginx server that returns its Pod name on / and ok on /health. The /manifest.bin location serves a file that Validate resilience with fault injection creates to show a bandwidth limit. Each application runs in the kong-air-production namespace with its own service account.

  2. Wait for the Kong Air deployments to be available:

    kubectl wait -n kong-air-production --for=condition=available --timeout=120s deployment --all

Validate

Confirm that each Kong Air pod is running with a Kong Mesh sidecar:

kubectl get pods -n kong-air-production

Every pod reports 2/2 in the READY column. One container runs the application, and the other runs the sidecar proxy.

FAQs

Run kongctl login once, or export your token in the KONGCTL_DEFAULT_KONNECT_PAT environment variable. See Authentication with kongctl.

Yes. Pass --control-plane-url instead of --control-plane-id, --region, --base-url, and --pat. See Choosing a control plane and a 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!