You are browsing documentation for an older version. See the latest documentation here.
Create a Route
These examples require that you have
jq
installed on your machine. You can also use the Konnect UI to configure services and routes.
Once your DataPlane
is deployed it receives configuration from Konnect, but there are no routing rules available for Kong Gateway to proxy traffic. You can use Konnect API to configure and test routing.
Before you begin
- In Gateway Manager, navigate to the Overview page of the control plane to which you added the data plane.
- Copy the ID of the control plane in the About this Hybrid Control Plane section.
-
Set the value of the variable
CP_UUID
to the ID of the control plane that you copied.export CP_UUID="a62e9a4c-d47..."
- Generate a personal access token to use the Konnect API.
-
Set the value of the variable
KONNECT_TOKEN
to the personal access token that you generated.export KONNECT_TOKEN="kpat_pYyaCgDWv..."
Create Kong Entities
Create a service and a route in your Konnect control plane using the variables that you set.
The following commands create a service named Sample and a route that proxies all traffic to httpbin.konghq.com:
SERVICE_ID=$(curl -sS -H "Authorization: Bearer $KONNECT_TOKEN" https://us.api.konghq.com/v2/control-planes/$CP_UUID/core-entities/services -d name=Sample -d url=https://httpbin.konghq.com | jq -r .id)
curl -sS -H "Authorization: Bearer $KONNECT_TOKEN" https://us.api.konghq.com/v2/control-planes/$CP_UUID/core-entities/services/$SERVICE_ID/routes -d "paths[]=/"
Send test traffic
After the service and route are created, send traffic to the proxy and it will forward the request to httpbin.konghq.com. You can use httpbin’s /anything
endpoint to echo the request made in the response.
To make a request to the proxy, fetch the LoadBalancer IP address using kubectl get services
:
export PROXY_IP=$(kubectl get services -n kong -o json | jq -r '.items[] | .status.loadBalancer?|.ingress[]?|.ip')
echo "Proxy IP: $PROXY_IP"
Note: If your cluster can’t provision LoadBalancer type Services, then you might not receive an IP address.
Test the routing rules by sending a request to the proxy IP address:
curl $PROXY_IP/anything/hello
Delete the test service
You can delete the test service after you verify that Kong Gateway Operator and Konnect are working.
To delete the Sample
service.
curl -sS -H "Authorization: Bearer $KONNECT_TOKEN" https://us.api.konghq.com/v2/runtime-groups/$CP_UUID/core-entities/services/$SERVICE_ID -X DELETE
Next steps
Now that you have a DataPlane
that has configuration from Konnect you can explore all of the capabilities that Kong Gateway provides.