curl -i "$PROXY_IP/echo" \
--no-progress-meter --fail-with-body
Copied!
Create a Gateway API HTTPRoute object.
This page is part of the Get started with Kong Operator and Gateway API series.
Complete the previous page, Provision a Gateway before completing this page.
In order to route a request using Kong Gateway we need a Service running in our cluster. Install an echo Service using the following command:
kubectl apply -f https://developer.konghq.com/manifests/kic/echo-service.yaml -n kong
Create an HTTPRoute to send any requests that start with /echo to 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 -
The results should look like this:
httproute.gateway.networking.k8s.io/echo created
Run kubectl get gateway kong -n default to get the IP address for the gateway and set that as the value for the variable PROXY_IP.
export PROXY_IP=$(kubectl get gateway kong -n kong -o jsonpath='{.status.addresses[0].value}')
Test your Service:
curl -i "$PROXY_IP/echo" \
--no-progress-meter --fail-with-body
curl -i "$PROXY_IP/echo" \
--no-progress-meter --fail-with-body
You should see the following message:
Welcome, you are connected to node king.
Running on Pod echo-965f7cf84-rm7wq.
In namespace default.
With IP address 192.168.194.10.