curl -i "http://$PROXY_IP/echo" \
--no-progress-meter --fail-with-bodyConfigure route and service
Create a Gateway API HTTPRoute object.
Prerequisites
Series Prerequisites
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.
Create a Backend Service
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 kongCreate an HTTPRoute
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 createdTest your Backend
-
Wait for the
Gatewayto be programmed:kubectl wait --for=condition=Programmed gateway/kong -n kong --timeout=5m -
Run
kubectl get gateway kong -n kongto 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}') -
Test your Service:
You should see the following message:
Welcome, you are connected to node kind-control-plane. Running on Pod echo-5f44d4c6f9-krnhk. In namespace kong. With IP address 10.244.0.26.