Skip to main content

Run API7 Gateway Data Planes Outside Kubernetes

API7 Ingress Controller can manage a gateway group whose data plane instances run outside the Kubernetes cluster, for example on Docker or RPM hosts. You keep declaring routes with Gateway API, Ingress, or APISIX custom resources. The gateways that serve the traffic stay on hosts you operate separately from the cluster.

The controller still runs in the cluster and sends configuration to the API7 control plane. The control plane itself can run in the same cluster, in another cluster, or on its own hosts. Each external gateway watches the DP Manager for its gateway group and sends application traffic directly to the backends:

Prerequisites​

Complete the following prerequisites:

  • An API7 Gateway control plane and a license for the external gateway instances.
  • A Kubernetes cluster and tools that meet the API7 Ingress Controller setup prerequisites.
  • External hosts supported by the API7 Gateway deployment package you will use.
  • A load balancer or routed virtual address in front of the external gateways.

Prepare Network Routes​

Application traffic does not pass through the controller or the control plane. Allow a route for each path:

SourceDestinationPurpose
Ingress Controller podsAPI7 Admin API addressSynchronize configuration for the gateway group.
External gatewaysDP Manager mTLS address, normally port 7943Watch configuration and report instance status.
Clients or the external load balancerGateway proxy listenersSend application traffic.
External gatewaysBackend addresses generated from Kubernetes resourcesReach application pods or a Service address available outside the cluster.

The Admin API and the DP Manager serve different callers. The controller does not connect to the DP Manager, and the gateways do not use the Admin API to watch configuration.

Deploy the Controller and External Gateways​

Follow Set Up Ingress Controller and Gateway. Add the gateway instances with Docker or RPM deployments instead of a Kubernetes deployment:

  1. In Gateway Settings → Deployment, set Admin API Address to an address the controller pods can reach. Set DP Manager Address to the mTLS address every external gateway host can reach.
  2. Add a gateway group of type Ingress Controller.
  3. Install the controller and apply the generated GatewayProxy, as described in Deploy the Controller and Gateway. Skip the step that deploys a gateway instance in Kubernetes when the group will contain only external gateways.
  4. In Gateway Instances for this gateway group, add each external gateway and run the generated Docker or RPM deployment on its host.
  5. Put the gateway proxy listeners behind the external load balancer. Configure its health checks as described in External load balancer checks.

The generated connection values and certificates belong to this gateway group. Do not reuse values generated for another group. For the installation on the host, see Add the Data Plane Gateway or Onboard the Data-Plane Gateway.

Make Kubernetes Backends Reachable​

Each external gateway connects directly to the backend addresses the controller writes. Which addresses those are depends on the routing resource:

Routing resourceAddresses the controller writesGateways must reach
Gateway API HTTPRoute or Kubernetes Ingress with a ClusterIP ServiceReady EndpointSlice addressesPod IPs
Gateway API HTTPRoute or Kubernetes Ingress with an ExternalName ServiceThe Service's external DNS nameThe DNS name and its resolved addresses
ApisixRoute, by defaultEndpointSlice addressesPod IPs
ApisixRoute with resolveGranularity: serviceThe Service addressService ClusterIP

On an ApisixRoute, resolveGranularity accepts endpoint or service. The endpoint value is singular. An HTTPRoute or Ingress that references an ExternalName Service does not use EndpointSlice addresses; the external gateways resolve and connect to the Service's external DNS name.

To reach pod IPs, prepare the path between the gateway hosts and the pod network:

  • In a routed pod network, advertise the pod CIDRs to the gateway network and check the return path from the pods.
  • Where the network uses SNAT or masquerading, check which source address the application sees.
  • Allow the gateway traffic in a NetworkPolicy or in the CNI policy that replaces it.

Before sending client traffic, list the application's ready endpoints:

kubectl get endpointslice -n <application-namespace> \
-l kubernetes.io/service-name=<service-name> -o wide

On each gateway host, request one of those addresses. Replace /health with a path the application serves:

curl --fail-with-body "http://<ready-pod-ip>:<target-port>/health"

A response shows that the host can reach that endpoint. Repeat the test after a pod is replaced.

Publish the External Gateway Address​

Gateway and Ingress resources can report the external load balancer address in their status. Add statusAddress to the GatewayProxy generated by API7 Dashboard, and keep the generated provider configuration:

apiVersion: apisix.apache.org/v1alpha1
kind: GatewayProxy
metadata:
name: <gateway-proxy-name>
namespace: <controller-namespace>
spec:
statusAddress:
- <external-load-balancer-ip>
# Keep the generated provider configuration here.

Apply the complete GatewayProxy manifest. statusAddress updates the reported status. It does not configure the load balancer or open a gateway listener.

Verify Configuration and Traffic​

In Gateway Instances, confirm that every external gateway reports a Healthy status. This shows that the gateway is connected to the control plane. A healthy gateway can still lack a route to the pod network.

Then follow Proxy Requests to a Service through Create a Route. Send the /ip request to every external gateway instead of port-forwarding the in-cluster gateway Service. Replace the addresses and port 9080 with each gateway's proxy listener:

export DP_A_ORIGIN="http://GATEWAY_A_ADDRESS:9080"
export DP_B_ORIGIN="http://GATEWAY_B_ADDRESS:9080"

for origin in "$DP_A_ORIGIN" "$DP_B_ORIGIN"; do
curl --fail-with-body "$origin/ip"
done

Each request should return the HTTPBIN response. Then send the same request through the external load balancer.

Plan Session Affinity​

Use consistent hashing when requests with the same session key should prefer the same backend. The control plane distributes that configuration, not application session state.

For a Gateway API or Kubernetes Ingress backend, save the following BackendTrafficPolicy as affinity.yaml. The policy targets the backend Service:

affinity.yaml
apiVersion: apisix.apache.org/v1alpha1
kind: BackendTrafficPolicy
metadata:
name: <service-name>-session-affinity
namespace: <application-namespace>
spec:
targetRefs:
- group: ""
kind: Service
name: <service-name>
loadbalancer:
type: chash
hashOn: header
key: X-Session-ID

For an ApisixRoute backend, save this ApisixUpstream instead. Its name and namespace match the backend Service:

affinity.yaml
apiVersion: apisix.apache.org/v2
kind: ApisixUpstream
metadata:
name: <service-name>
namespace: <application-namespace>
spec:
ingressClassName: <ingress-class-name>
loadbalancer:
type: chash
hashOn: header
key: X-Session-ID

Apply the resource for your routing API:

kubectl apply -f affinity.yaml

The same key selects the same backend only while the gateways share the same backend set and can read the same key. A pod change, a health difference, a retry, or a missing key can select another backend. Upstreams and Load Balancing describes each case.

If many clients reach the gateways through one NAT address, the remote_addr fallback can concentrate their requests on one backend. Prefer a session identifier in a trusted header or cookie, and check that every entry path keeps it.

Test through each gateway before enabling the load balancer. The applied resource hashes on the X-Session-ID header, and the application response should identify the backend pod:

export SESSION_KEY="test-session-1"

for origin in "$DP_A_ORIGIN" "$DP_B_ORIGIN"; do
curl --fail-with-body "$origin/<session-check-path>" \
-H "X-Session-ID: $SESSION_KEY"
done

Repeat the test after a pod restart, a scale event, and a failed backend. The session can move to another backend after any of these.

Next Steps​