Create a Route with Kong Operator with self-managed Control Plane
Create a Service, then create an HTTPRoute.
Prerequisites
Series Prerequisites
This page is part of the Deploy self-managed Control Plane with Kong Operator series.
Complete the previous page, Create a Gateway before completing this page.
Configure the echo service
-
In order to route a request using Kong Gateway we need a Service running in our cluster. Install an
echoService using the following command:kubectl apply -f https://developer.konghq.com/manifests/kic/echo-service.yaml -n kongCopied! -
Create an
HTTPRouteto send any requests that start with/echoto the echo Service.echo ' kind: HTTPRoute apiVersion: gateway.networking.k8s.io/v1 metadata: name: echo namespace: kong spec: parentRefs: - group: gateway.networking.k8s.io kind: Gateway name: kong rules: - matches: - path: type: PathPrefix value: /echo backendRefs: - name: echo port: 1027 ' | kubectl apply -f -Copied!The results should look like this:
httproute.gateway.networking.k8s.io/echo createdCopied!
Test the configuration
-
Run
kubectl get gateway kong -n defaultto get the IP address for the gateway and set that as the value for the variablePROXY_IP.export PROXY_IP=$(kubectl get gateway kong -n kong -o jsonpath='{.status.addresses[0].value}')Copied!Note: if your cluster can not provision LoadBalancer type Services then the IP you receive may only be routable from within the cluster.
-
Make a call to the
$PROXY_IPthat you configured.curl "$PROXY_IP/echo" \ --no-progress-meter --fail-with-bodyCopied!curl "$PROXY_IP/echo" \ --no-progress-meter --fail-with-bodyCopied! -
You should see the following:
Welcome, you are connected to node king. Running on Pod echo-965f7cf84-rm7wq. In namespace default. With IP address 192.168.194.10.Copied!