Skip to main content
Version: Next

Configure Routes

Apache APISIX provides flexible gateway management capabilities based on routes, in which routing paths and target upstreams are defined.

This tutorial guides you through creating a Route using the APISIX Ingress Controller and verifying its behavior. You’ll configure a Route to a sample Upstream pointing to an httpbin service, then send a request to observe how APISIX proxies the traffic.

Prerequisites#

  1. Complete Get APISIX and APISIX Ingress Controller.

Set Up a Sample Upstream#

Install the httpbin example application on the cluster to test the configuration:

kubectl apply -f https://raw.githubusercontent.com/apache/apisix-ingress-controller/refs/heads/v2.0.0/examples/httpbin/deployment.yaml

Configure a Route#

In this section, you will create a Route that forwards client requests to the httpbin example application, an HTTP request and response service.

You can use either Gateway API, Ingress, or APISIX CRD resources to configure the route.

important

If you are using Gateway API, you should first configure the GatewayClass and Gateway resources:

Show configuration
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: apisix
spec:
controllerName: apisix.apache.org/apisix-ingress-controller
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: apisix
spec:
gatewayClassName: apisix
listeners:
- name: http
protocol: HTTP
port: 80
infrastructure:
parametersRef:
group: apisix.apache.org
kind: GatewayProxy
name: apisix-config

If you are using Ingress or APISIX custom resources, you can proceed without additional configuration.

Create a Kubernetes manifest file for a Route that proxy requests to httpbin:

httpbin-route.yaml
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: getting-started-ip
spec:
parentRefs:
- name: apisix
rules:
- matches:
- path:
type: Exact
value: /ip
backendRefs:
- name: httpbin
port: 80

Apply the configurations to your cluster:

kubectl apply -f httpbin-route.yaml

Verify#

Expose the service port to your local machine by port forwarding:

kubectl port-forward svc/apisix-gateway 9080:80 &

Send a request to the Route:

curl "http://127.0.0.1:9080/ip"

You should see a response similar to the following:

{
"origin": "127.0.0.1"
}