Deploy the public gateway

TL;DR

Create a GatewayConfiguration with controlPlaneOptions.watchNamespaces.type: own, then create the matching GatewayClass and Gateway in the tenant namespace.

Prerequisites

This page is part of the Deploy multiple isolated gateways on the same cluster series.

Complete the previous page, Install Kong Operator for multi-tenancy before completing this page.

Create a GatewayConfiguration

The controlPlaneOptions.watchNamespaces.type: own field restricts the in-memory KIC for this gateway to watch only the kong-gw-public namespace. Without this, it would watch all namespaces and process routes belonging to other tenants.

echo '
kind: GatewayConfiguration
apiVersion: gateway-operator.konghq.com/v2beta1
metadata:
  name: gw-public
  namespace: kong-gw-public
spec:
  dataPlaneOptions:
    deployment:
      podTemplateSpec:
        spec:
          containers:
          - name: proxy
            image: kong/kong-gateway:3.15
  controlPlaneOptions:
    watchNamespaces:
      type: own
' | kubectl apply -f -

Create a GatewayClass

  1. Create a GatewayClass that references the GatewayConfiguration above:

    echo '
    kind: GatewayClass
    apiVersion: gateway.networking.k8s.io/v1
    metadata:
      name: gw-public
    spec:
      controllerName: konghq.com/gateway-operator
      parametersRef:
        group: gateway-operator.konghq.com
        kind: GatewayConfiguration
        name: gw-public
        namespace: kong-gw-public
    ' | kubectl apply -f -
  2. Wait for Kong Operator to accept the GatewayClass:

    kubectl wait --for=condition=Accepted=True gatewayclass/gw-public --timeout=60s

Create a Gateway

  1. Create the Gateway resource in the kong-gw-public namespace, referencing the GatewayClass above:

    echo '
    kind: Gateway
    apiVersion: gateway.networking.k8s.io/v1
    metadata:
      name: gw-public
      namespace: kong-gw-public
    spec:
      gatewayClassName: gw-public
      listeners:
      - name: http
        protocol: HTTP
        port: 80
    ' | kubectl apply -f -
  2. Wait for the gateway to be programmed:

    kubectl wait --for=condition=Programmed=True gateway/gw-public -n kong-gw-public --timeout=120s
  3. This gateway’s in-memory KIC is the first ControlPlane in the cluster, so it’s the one that picks up the KongLicense you applied in the previous step. Confirm it reached the Programmed condition:

    kubectl wait --for=jsonpath='{.status.controllers[0].conditions[0].status}'=True \
     konglicense/kong-license --timeout=60s

Validate

Verify the public gateway was reconciled successfully:

You can verify the Gateway was reconciled successfully by checking its Programmed condition.

kubectl get -n kong-gw-public gateway gw-public \
  -o=jsonpath='{.status.conditions[?(@.type=="Programmed")]}' | jq

The output should look similar to this:

{
  "observedGeneration": 1,
  "reason": "Programmed",
  "status": "True",
  "type": "Programmed"
}

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!