Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KrakenD API Gateway #328

Open
NapalmCodes opened this issue Dec 11, 2024 · 0 comments
Open

KrakenD API Gateway #328

NapalmCodes opened this issue Dec 11, 2024 · 0 comments
Labels
integration A new .NET Aspire integration

Comments

@NapalmCodes
Copy link

.NET Aspire issue link

dotnet/aspire#5452

Overview

I propose adding a new component to the CommunityToolkit: the KrakenD API Gateway component, which I have developed and is available here. This component enables developers to leverage KrakenD’s powerful API Gateway capabilities locally, enhancing the testing and development experience when working with microservice-based architectures.

Key Features

This component facilitates the following essential features for API Gateway development:

  • Centralized API Management
    • Simplifies routing and discovery for microservices.
  • Custom Header Control
    • Enables fine-grained management of headers passed to consuming services.
  • Caching
    • Improves performance by caching responses to reduce load on backend services.
  • Input Sanitization
    • Filters and validates incoming requests before reaching backend services.
  • Data Transformation
    • Supports modifying request and response payloads to meet specific requirements.
  • API Versioning
    • Smoothly manages API evolution without impacting client applications.
  • Extensibility
    • Allows developers to easily incorporate additional features as needed.

Facilitated Patterns and Practices

By leveraging this component, developers can implement several common patterns and practices:

  • Backends for Frontends (BFF)
    • Provides client-specific APIs for optimized interaction with backend services.
  • API Composition
    • Combines responses from multiple APIs into a single, unified payload for efficiency.
  • Security Proxy
    • Acts as a central hub for token authentication, authorization, and data masking.
  • Content-Based Routing
    • Dynamically routes requests based on payload or header content.
  • Anti-Corruption Layer
    • Translates external client protocols and data formats into internal standards to maintain system consistency.
  • Throttling and Quota Management
    • Implements rate limits and quotas to protect backend services from abuse or overuse.

Benefits

This component serves as a versatile tool for both development and production environments, empowering developers to:

  • Simulate production-like API Gateway functionality locally.
  • Accelerate development cycles by streamlining API management tasks.
  • Improve reliability and security of their microservice-based systems.

Why Add This to CommunityToolkit?

KrakenD is a widely adopted, high-performance API Gateway. By including this component in the CommunityToolkit, we can:

  • Provide developers with a standardized, easy-to-use framework for local API Gateway testing.
  • Promote best practices for microservice architectures.

I’d be thrilled to contribute this component and work with the community to enhance its capabilities further!

Usage example

Example can be found here.

For reference:

// Configuration path is used to create a bind mount to copy local `krakend.json` config
// to the container.
// https://www.krakend.io/docs/configuration/
// https://learn.microsoft.com/en-us/dotnet/aspire/fundamentals/persist-data-volumes

var krakend = builder.AddKrakend("gateway", "./config/krakend", port: 8080) 
    .WithExternalHttpEndpoints()
    .WithEnvironment("FC_OUT", "/tmp/krakend.json"); // Optional: Helpful for troubleshooting flexible config issues
                                                     // (may want a bind mount for easy local access while debugging).

And optional sidecar (built with YARP) to enable service discovery with Aspire locally:

krakend.WithProxy(configurationPath: "./config/proxy", port: 8081);

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration A new .NET Aspire integration
Projects
None yet
Development

No branches or pull requests

2 participants