Configure an ExternalService
Uses:
Kong Ingress Controller
Deployment Platform
Related Documentation
Related Resources
TL;DR
Configure an ExternalName service, then create an HTTPRoute to route traffic to the service.
Prerequisites
Kong Konnect
If you don’t have a Konnect account, you can get started quickly with our onboarding wizard.
- The following Konnect items are required to complete this tutorial:
- Personal access token (PAT): Create a new personal access token by opening the Konnect PAT page and selecting Generate Token.
-
Set the personal access token as an environment variable:
export KONNECT_TOKEN='YOUR KONNECT TOKEN'Copied!
Create an ExternalName Kubernetes service
Use the following command to create an external Kubernetes service:
echo '
kind: Service
apiVersion: v1
metadata:
name: proxy-to-httpbin
namespace: kong
spec:
ports:
- protocol: TCP
port: 80
type: ExternalName
externalName: httpbin.konghq.com
' | kubectl apply -f -
Copied!
Create an HTTPRoute
To route HTTP traffic, you need to create an HTTPRoute or an Ingress resource pointing at your Kubernetes Service.
Validate your configuration
Once the resource has been reconciled, you’ll be able to call the /httpbin endpoint and Kong Gateway will route the request to the external httpbin service.
curl "$PROXY_IP/httpbin/anything" \
--no-progress-meter --fail-with-body
Copied!
curl "$PROXY_IP/httpbin/anything" \
--no-progress-meter --fail-with-body
Copied!
Cleanup
Uninstall KIC from your cluster
helm uninstall kong -n kong
Copied!