# 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:

API7 control plane*In or outside Kubernetes*

External hosts

Kubernetes cluster

**Admin API**Receives the desired configuration

**DP Manager**Serves the gateway group configuration

configuration updates

**API7 Ingress Controller**Translates Kubernetes resources

resolves backend addresses

mTLS configuration watch

**External load balancer**Client entry point

**Gateway A**Docker or RPM host

**Gateway B**Docker or RPM host

application traffic

**Application pods**Pod IPs or Service ClusterIP

## Prerequisites[​](#prerequisites "Direct link to 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](https://docs.api7.ai/ingress-controller/set-up-ingress-controller-and-gateway.md#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[​](#prepare-network-routes "Direct link to Prepare Network Routes")

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

| Source                                | Destination                                           | Purpose                                                                    |
| ------------------------------------- | ----------------------------------------------------- | -------------------------------------------------------------------------- |
| Ingress Controller pods               | API7 Admin API address                                | Synchronize configuration for the gateway group.                           |
| External gateways                     | DP Manager mTLS address, normally port `7943`         | Watch configuration and report instance status.                            |
| Clients or the external load balancer | Gateway proxy listeners                               | Send application traffic.                                                  |
| External gateways                     | Backend addresses generated from Kubernetes resources | Reach 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[​](#deploy-the-controller-and-external-gateways "Direct link to Deploy the Controller and External Gateways")

Follow [Set Up Ingress Controller and Gateway](https://docs.api7.ai/ingress-controller/set-up-ingress-controller-and-gateway.md#set-up-api7-ingress-controller). 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](https://docs.api7.ai/ingress-controller/set-up-ingress-controller-and-gateway.md#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](https://docs.api7.ai/api7-gateway/how-to-guides/ops/configure-readiness-probe.md#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](https://docs.api7.ai/api7-gateway/install/deploy-with-docker-compose.md#step-9-add-the-data-plane-gateway) or [Onboard the Data-Plane Gateway](https://docs.api7.ai/api7-gateway/install/deploy-with-rpm.md#onboard-dp).

## Make Kubernetes Backends Reachable[​](#make-kubernetes-backends-reachable "Direct link to 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 resource                                                         | Addresses the controller writes | Gateways must reach                     |
| ------------------------------------------------------------------------ | ------------------------------- | --------------------------------------- |
| Gateway API HTTPRoute or Kubernetes Ingress with a ClusterIP Service     | Ready EndpointSlice addresses   | Pod IPs                                 |
| Gateway API HTTPRoute or Kubernetes Ingress with an ExternalName Service | The Service's external DNS name | The DNS name and its resolved addresses |
| `ApisixRoute`, by default                                                | EndpointSlice addresses         | Pod IPs                                 |
| `ApisixRoute` with `resolveGranularity: service`                         | The Service address             | Service `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[​](#publish-the-external-gateway-address "Direct link to 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[​](#verify-configuration-and-traffic "Direct link to 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](https://docs.api7.ai/ingress-controller/proxy-requests-to-a-service.md) through [Create a Route](https://docs.api7.ai/ingress-controller/proxy-requests-to-a-service.md#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[​](#plan-session-affinity "Direct link to 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](https://docs.api7.ai/api7-gateway/key-concepts/upstreams-and-load-balancing.md#session-affinity-across-gateway-instances) 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[​](#next-steps "Direct link to Next Steps")

* [Configure High Availability](https://docs.api7.ai/ingress-controller/high-availability.md) for the controller reconciliation path.
* [Upstreams and Load Balancing](https://docs.api7.ai/api7-gateway/key-concepts/upstreams-and-load-balancing.md#session-affinity-across-gateway-instances) for the gateway’s consistent-hashing behavior.
* [Troubleshoot Manifest Translation and Synchronization](https://docs.api7.ai/ingress-controller/troubleshooting/configuration-synchronization.md) when a Kubernetes change does not reach the gateway group.
