Deploy an API gateway in Kubernetes
You currently have a K8s cluster with an API (micro)service and want to deliver it to production with additional features and protection, like rate limiting, authentication, and DDoS protection.
In this guide, you'll learn how to implement ngrok as an API gateway, using the ngrok Kubernetes Operator, in these steps:
- Apply the ngrok Kubernetes Operator to your cluster
- Configure your cluster to use ngrok as an API gateway
- Set up Traffic Policy to shape traffic into/out of your API service
What you'll need
ngrok account
Any tier will do— register now.
A reserved domain
Grab yours in the ngrok dashboard.
A Kubernetes cluster
... and optionally, a functioning API service. If you don't yet have one, you can install our demo service.
kubectl
and Helm
Both installed locally on your workstation.
Why use the K8s Gateway API for your API gateway?
Kubernetes has two APIs for handling ingress from external traffic into your cluster's internal network: the original Ingress Controller or the Gateway API.
The ngrok Kubernetes Operator supports both mechanisms. While we encourage you to explore both, we recommend the Gateway API based on the following:
- The Ingress API, which Ingress Controllers utilize, is frozen in new versions of K8s and no longer receives updates.
- While the Ingress Controller is designed purely for ingress, the Gateway API is also designed for dynamic infrastructure provisioning and advanced traffic routing.
- The Gateway API is role-oriented, allowing DevOps/platform/infrastructure engineering teams to control clusters, policies, and permissions centrally, while still allowing API developers to self-service endpoints to their services with route objects.
- The Gateway API provides a common interface to K8s networking, removing reliance on vendor-specific configurations.
- Many developers can integrate their APIs or apps onto a single
GatewayClass
orGateway
, usingHTTPRoute
s, without affecting others.
For the scope of this guide, and based on this recommendation, we'll focus on Gateway API.