KrakenD API Gateway
website·Indexed 35 days ago
https://www.krakend.io/docs/A high-performance API Gateway featuring a flexible, template-based configuration system. Documentation covers installation, backend configuration, and advanced routing. Includes details on the Enterprise edition, featuring dynamic routing, virtual hosts, SOAP backend integration, gRPC support, and hot reload capabilities.
What's inside KrakenD
- Request and response modifier plugins allow developers to implement custom business logic directly on requests and responses. They are injected at the beginning of the proxy pipe (after the router layer and before the request executor). Unlike handler plugins, these are modifier functions called sequentially. Request modifiers can inspect and modify requests, while response modifiers handle responses. They are executed in the order they are declared in the configuration.
Overview of KrakenD HTTP Client Plugins
HTTP client plugins execute in the proxy layer when KrakenD communicates with backends. They allow for intercepting, transforming, and manipulating requests before they hit backend services and on their way back.
Critical Constraints:
- No Chaining: You cannot chain HTTP client plugins; only one plugin is allowed per backend connection.
- Replacement Behavior: An HTTP client plugin replaces KrakenD's default HTTP client. Consequently, built-in features like Client Credentials, Backend Cache, and Backend Telemetry will stop working unless you manually implement that logic within your plugin.
Overview of Telemetry and Monitoring in KrakenD
KrakenD provides telemetry and monitoring to help detect root causes of problems, analyze distributed transactions, and optimize performance and latency. The current recommended standard for new projects is OpenTelemetry (OTEL), which provides a vendor-neutral framework for collecting metrics and traces.
Previous integrations include OpenCensus and the Metrics API (InfluxDB exporter), both of which are now frozen in development in favor of OpenTelemetry.
Overview of KrakenD Traffic Management features
KrakenD provides a suite of traffic management tools to monitor, control, and optimize request flow, prevent abuse, and ensure API performance. These features can be used independently or combined:
- Rate-Limiting: Controls request volume from users or toward backends.
- Circuit Breaker: Prevents cascading failures by temporarily halting requests to failing backends.
- Bot Detection: Uses regular expressions to identify and block malicious bots.
- Geofencing (Enterprise): Restricts API usage based on geographical location (countries/cities).
- IP Filtering (Enterprise): Blocks traffic from specific IP addresses.
Overview of KrakenD HTTP Server Plugins
HTTP Server Plugins (also known as handler plugins) operate at the router layer of KrakenD. They allow developers to modify incoming requests before processing begins or modify the final response sent to the user. These plugins act as black boxes exposing anhttp.Handlerand can be used to implement custom monetization, tracking, tenant control, protocol conversion, or other heavy request/response modifications. Because they wrap elements in the pipe, chaining multiple plugins adds overhead due to repeated decoding and encoding of the body; it is generally more performant to have one plugin perform multiple tasks than multiple plugins performing one task each.Overview of KrakenD Go plugins
KrakenD plugins are soft-linked libraries (.sofiles) based on Go plugins. They allow developers to inject custom business logic into the KrakenD processing pipeline without forking the official source code. Go plugins generally offer significantly higher performance (approximately 10x) compared to Lua scripts.Overview of KrakenD Non-REST Connectivity
KrakenD provides several built-in capabilities to integrate with non-REST services, allowing developers to mix multiple protocols and expose them via a REST interface. Available integrations include:
- RabbitMQ: Consumer and Producer for bidirectional messaging.
- Pub/Sub: Support for Apache Kafka, AWS SNS, SQS, Azure Service Bus, GCP PubSub, and NATS.io.
- GraphQL: Efficient aggregation for complex data queries.
- AWS Lambda: Direct invocation of serverless functions.
- Async Agents: Event-driven, non-blocking processing for decoupled workflows.
- Enterprise Only: gRPC (Client and Server), WebSockets (real-time bidirectional data), and SOAP (legacy XML service integration).
Overview of the KrakenD Revoke Server
The Revoke Server (Revoker) is a standalone server used in KrakenD Enterprise to coordinate token revocation across a cluster. It allows centralized management of token expiration by pushing revocation instructions to all registered KrakenD instances via their Bloom filter RPC port. The Revoker does not issue tokens; it only instructs gateways to reject tokens that are still technically valid based on their expiration date. Interaction with the Revoker is handled via a REST API.Overview of Extended Flexible Configuration in KrakenD Enterprise
Extended Flexible Configuration allows KrakenD users to manage API Gateway configurations using multiple files, reusable code blocks, and a template system. It supports$reffor replacing configuration blocks with external files and Go-based templates (text/template) for dynamic content, conditionals, and iterations. It is compatible with various formats including JSON, YAML, and TOML.{ "version": 3, "extra_config": { "$ref": "./service/extra_config.json" } }Overview of KrakenD Enterprise
KrakenD Enterprise is a high-performance, stateless API Gateway built on the Lura Project. It is designed for linear scalability and immutable infrastructure, supporting GitOps practices without requiring node coordination or a persistence layer. Key capabilities include centralized authentication, RBAC, API documentation generation, and advanced observability (logs, metrics, and traces). It maintains configuration compatibility with the Community Edition, allowing users to move between versions without changing the settings file.Overview of Pub/Sub backend integrations
KrakenD supports integrating endpoints with event-driven architectures using publish/subscribe backends. This allows REST interfaces to push events to queues or consume the latest events. Supported technologies include:
- NATS.io
- RabbitMQ
- Apache Kafka
- AWS SNS and SQS
- Azure Service Bus Topics and Subscriptions
- GCP PubSub
To implement this, use the
backend/pubsub/subscriberandbackend/pubsub/publishernamespaces within theextra_configof the backend section.Overview of Authentication and Authorization in KrakenD
KrakenD separates Authentication (AuthN) — verifying identity — from Authorization (AuthZ) — verifying access rights. Because the gateway sits between the client and the backend, it allows for independent security configurations on both sides.
Common architectural scenarios include:
- No auth: Public endpoints.
- Delegated auth: Gateway forwards auth headers to the backend.
- Clients auth: Client is authenticated at the gateway; gateway-to-backend communication is open.
- Clients and gateway auth: Independent authentication for both client-to-gateway and gateway-to-backend.
- Gateway auth: Public access for clients; authenticated communication between gateway and backend.