Join our Newsletter — 33% off our NHI Course

What are the best practices for API gateway placement in a Kubernetes cluster?

Place the API gateway at the cluster edge, before services, so it can centralise authentication, rate limiting, request validation, and routing. Keep internal services private, restrict direct pod access, and separate ingress concerns from service-to-service traffic. Check that gateway policies, TLS handling, and observability cover every exposed route.

Where an API Gateway Belongs in a Kubernetes Cluster

An api gateway works best at the cluster edge, where it can terminate and enforce policy before requests reach internal services. That placement gives you one control point for authentication, rate limiting, validation, and routing, while preserving private service networks behind it. It also keeps ingress handling separate from east-west traffic inside the cluster.

The practical advantage is architectural clarity. A gateway at the edge reduces duplicated security logic in every workload and makes external exposure easier to reason about. For API-specific attack patterns, the gateway is the right place to screen for broken object access, abuse of exposed routes, and excessive consumption before traffic fans out into the cluster, as covered in the OWASP API Security Top 10.

In Kubernetes terms, the gateway should sit in front of services, not beside them as a peer that can be bypassed. Internal services should remain reachable only through the gateway or tightly controlled in-cluster paths, with direct pod access restricted. That design keeps external trust boundaries explicit and prevents ingress concerns from leaking into service-to-service communication.

What Good Gateway Placement Looks Like Operationally

Good placement is not just about location, it is about responsibility. The gateway should own edge admission, protocol normalization, and request-level controls, while the cluster network and service mesh or internal routing handle private service communication. That separation avoids a common failure mode where teams assume the gateway protects every request, including direct internal calls.

For Kubernetes clusters, that usually means combining the gateway with namespace isolation, network policies, and admission controls so the edge is not the only barrier. The cluster still needs internal safeguards because once traffic is inside, a compromised workload may try to move laterally or reach admin interfaces. NHI-aware hardening guidance for clusters, including service accounts, tokens, and RBAC, is captured in the Kubernetes NHI Security Guide.

Gateway policies also need to match the actual route inventory. If a cluster exposes multiple APIs, versions, or partner-specific paths, every route should inherit the same baseline of TLS handling, logging, validation, and rate limiting unless there is a deliberate exception. Otherwise, you end up with a secure front door and overlooked side doors.

TLS, Observability, and Internal Trust Boundaries

TLS handling should be designed deliberately at the edge. Decide whether the gateway terminates TLS, re-encrypts to backends, or passes through end-to-end encryption, then verify that certificate trust, header handling, and identity propagation remain consistent. If the gateway decrypts traffic, it becomes a high-value enforcement point and must be treated as such in configuration and monitoring.

Observability is part of placement, not an afterthought. The gateway should emit logs and metrics that show which routes are exposed, which requests were blocked, which identities were authenticated, and where policy exceptions exist. That evidence helps you confirm that the gateway is covering every published route rather than only the ones the platform team remembers. For broader cluster hardening, including control-plane, network policy, admission, and runtime concerns, the Kubernetes Security Guide is the better companion resource.

Placement also affects how you handle APIs that are part of a larger container platform. If the gateway is too far inside the cluster, external clients may still hit exposed services, load balancers, or admin endpoints directly. If it is too far out without clear service boundaries, it can become a bottleneck or a weakly governed proxy for too many responsibilities. The placement goal is a single external choke point with clearly private internal services.

Risk and Threat Considerations

When the gateway is not at the edge, the cluster can accumulate exposed services, inconsistent policy enforcement, and hidden direct-access paths. That creates a larger attack surface and increases the chance that authentication, validation, or throttling is bypassed on one route while appearing sound on others.

Failure mechanism: An attacker or abusive client reaches an internal service through an exposed path that was never meant to be public, or bypasses gateway policy entirely by calling the service directly. Misplaced trust boundaries, weak route inventory, and uneven TLS or logging create the opening.

Impact: The result can be unauthorized access, request flooding, inconsistent audit coverage, and a wider blast radius if a single exposed service becomes the easiest entry point into the cluster.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP API Security Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5 sets the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP API Security Top 10 API8 — Security Misconfiguration API gateway placement determines exposed routes and control enforcement at the edge.
API9 — Improper Inventory Management Gateway coverage depends on knowing every published route, version, and hidden endpoint.
Recommendation — Place the gateway at the edge and enforce uniform policy on every exposed API route. Inventory all exposed APIs and block any route that is not intentionally published.
NIST SP 800-53 Rev 5 SC-7 — Boundary Protection Edge gateway placement is a boundary-control problem for externally reachable services.
AU-2 — Event Logging Gateway observability needs logging of authenticated, blocked, and routed API traffic.
AC-4 — Information Flow Enforcement Gateway policy governs what traffic may flow from external clients into cluster services.
Recommendation — Enforce boundary protection at the cluster edge and restrict direct access to internal services. Log gateway requests and policy decisions for every exposed route. Enforce information flow rules at the gateway before traffic reaches services.

Practitioner Guidance

What to verify: Confirm that every externally reachable API path is routed through the gateway, and that no service, ingress object, or admin endpoint remains directly reachable unless there is a documented exception. Also verify that route ownership is explicit, because gateway drift often starts with one team adding a “temporary” bypass.

Decision rule: If a backend must be callable from outside the cluster, it should normally be behind the gateway, not exposed as a separate public service. If a path is only for internal service-to-service use, keep it off the edge and enforce private network controls instead.

What good looks like: A single, documented edge policy layer handles external API exposure, while internal services stay private and observability proves which routes are public, which are internal, and which requests were denied.

Practitioner takeaway: Put the gateway where it can reliably define the cluster’s external trust boundary, then use Kubernetes controls to make sure nothing public can quietly bypass that boundary.