Create a Gateway
Create a GatewayConfiguration
object, the. createGatewayClass
instance and a Gateway
resource.
Prerequisites
Series Prerequisites
This page is part of the Deploy Kong Ingress Controller with Kong Gateway Operator series.
Complete the previous page, Install Kong Gateway Operator before completing this page.
ControlPlane and DataPlane resources
Creating GatewayClass
and Gateway
resources in Kubernetes causes Kong Gateway Operator to create a Kong Ingress Controller and Kong Gateway deployment.
You can customize your Kong Ingress Controller and Kong Gateway deployments using the GatewayConfiguration
CRD. This allows you to control the image being used, and set any required environment variables.
Create the GatewayConfiguration
In order to specify the KonnectExtension
in Gateway
’s configuration you need to create a GatewayConfiguration
object which will hold the KonnectExtension
reference.
echo '
kind: GatewayConfiguration
apiVersion: gateway-operator.konghq.com/v1beta1
metadata:
name: kong
namespace: kong
spec:
extensions:
- kind: KonnectExtension
name: my-konnect-config
group: konnect.konghq.com
dataPlaneOptions:
deployment:
replicas: 2
controlPlaneOptions:
deployment:
podTemplateSpec:
spec:
containers:
- name: controller
env:
- name: CONTROLLER_LOG_LEVEL
value: debug' | kubectl apply -f -
GatewayClass
To use the Gateway API resources to configure your Routes, you need to create a GatewayClass
instance and create a Gateway
resource that listens on the ports that you need.
echo '
kind: GatewayClass
apiVersion: gateway.networking.k8s.io/v1
metadata:
name: kong
namespace: kong
spec:
controllerName: konghq.com/gateway-operator
parametersRef:
group: gateway-operator.konghq.com
kind: GatewayConfiguration
name: kong
namespace: kong
---
kind: Gateway
apiVersion: gateway.networking.k8s.io/v1
metadata:
name: kong
namespace: kong
spec:
gatewayClassName: kong
listeners:
- name: http
protocol: HTTP
port: 80' | kubectl apply -f -
You can verify that everything works by checking the Gateway
resource via kubectl
:
kubectl get -n kong gateway kong -o wide
You should see the following output:
NAME CLASS ADDRESS PROGRAMMED AGE
kong kong 172.18.0.102 True 9m5s
Check the Programmed status
If the Gateway
has Programmed
condition set to True
, you can visit Konnect and see your configuration being synced by Kong Ingress Controller.
Check that Programmed
is True
on the kong
resource:
You can verify the Gateway
was reconciled successfully by checking its Programmed
condition.
kubectl get -n kong gateway kong \
-o=jsonpath='{.status.conditions[?(@.type=="Programmed")]}' | jq
The output should look similar to this:
{
"observedGeneration": 1,
"reason": "Programmed",
"status": "True",
"type": "Programmed"
}