Install Kong Operator for Kong Event Gateway

TL;DR

Create the kong and kafka namespaces, install Kong Operator, then deploy a Kafka cluster for the Event Gateway examples. For on-prem, also enable the GWAdmin and OnPremEventGateway controllers, store your Event Gateway license in a Secret, and create the control plane.

Prerequisites

You need a running Kubernetes cluster with kubectl configured to point at it. Any cluster works, whether it runs locally or in a cloud provider.

If you don’t have one, create a local cluster with minikube:

minikube start -p kong-demo

You will need Helm, a package manager for Kubernetes.

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'

Save an Event Gateway license with the event_gateway entitlement as event-gateway-license.jws in your working directory. This is a signed license token, not the JSON license file that Kong Gateway Enterprise uses.

This guide walks through a complete Kong Event Gateway setup using Kong Operator.

By the end of the series, you will have:

  • a Konnect Event Gateway control plane
  • an on-prem Event Gateway control plane that Kong Operator runs in your cluster
  • an Event Gateway data plane in Kubernetes
  • a backend Kafka cluster
  • a virtual cluster, listener, and listener policies
  • consumer and producer policies
  • two ways to expose services:
    • LoadBalancer and portMapping
    • Gateway, TLSRoute, and SNI

Create the Kubernetes namespaces

Create the namespaces used throughout this example:

kubectl create namespace kong
kubectl create namespace kafka

Install Kong Operator

Install Kong Operator with Helm:

If you want cert-manager to issue and rotate the admission and conversion webhook certificates, install cert-manager to your cluster and enable cert-manager integration by passing the following argument while installing, in the next step:

   --set global.webhooks.options.certManager.enabled=true

If you do not enable this, the chart will generate and inject self-signed certificates automatically. We recommend enabling cert-manager to manage the lifecycle of these certificates. Kong Operator needs a certificate authority to sign the certificate for mTLS communication between the control plane and the data plane. This is handled automatically by the Helm chart. If you need to provide a custom CA certificate, refer to the certificateAuthority section in the values.yaml of the Helm chart to learn how to create and reference your own CA certificate.

Create the control plane

With an on-prem control plane, Kong Event Gateway data planes pull their configuration from a control plane in your cluster. You deploy this control plane with a GWAdmin resource. For more information, see On-prem control plane.

  1. Store your Event Gateway license in a Secret. Kong Operator only reads Secrets that have the konghq.com/secret=true label:

    kubectl create secret generic gw-admin-license -n kong \
      --from-file=license=./event-gateway-license.jws
    kubectl label secret gw-admin-license -n kong konghq.com/secret=true
  2. Create the control plane:

    echo '
    apiVersion: gateway-operator.konghq.com/v1alpha1
    kind: GWAdmin
    metadata:
      name: gw-admin
      namespace: kong
    spec:
      license:
        secretRef:
          name: gw-admin-license
          key: license
    ' | kubectl apply -f -
  3. Wait for the control plane and its Pod to be ready:

    kubectl wait gwadmin/gw-admin -n kong \
      --for=condition=Ready=True \
      --timeout=5m
    
    kubectl wait deployment/gw-admin -n kong \
      --for=condition=Available=True \
      --timeout=5m

Install a Kafka cluster

The Event Gateway examples in this guide use a three-broker Kafka cluster deployed with the Bitnami chart.

  1. Add the Bitnami Helm repository:

    helm repo add bitnami https://charts.bitnami.com/bitnami
    helm repo update
  2. Write the Kafka configuration file:

    cat <<'EOF' >/tmp/kafka-values.yaml
    image:
      registry: docker.io
      repository: bitnamilegacy/kafka
      tag: 4.0.0-debian-12-r6
    
    listeners:
      client:
        protocol: PLAINTEXT
    externalAccess:
      enabled: false
    kraft:
      enabled: true
    controller:
      replicaCount: 3
    broker:
      replicaCount: 0
    EOF
  3. Install Kafka:

    helm install kafka-cluster bitnami/kafka \
      -n kafka \
      --version 32.4.3 \
      -f /tmp/kafka-values.yaml
  4. Wait for all Kafka brokers to be ready before continuing:

    kubectl wait pod -n kafka \
      --for=condition=Ready \
      --selector app.kubernetes.io/name=kafka \
      --timeout=5m

FAQs

The on-prem Kong Event Gateway control plane validates its license itself, and doesn’t start without a valid license. The LicenseProvisioned=True condition on the GWAdmin only means that the license Secret is mounted.

Check the control plane logs:

kubectl logs -n kong deployment/gw-admin

Make sure that the Secret holds the Event Gateway license token with the event_gateway entitlement, not a Kong Gateway Enterprise JSON license.

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!