
KrakenD Plugin Development Simplified
KrakenD is an open-source, ultra-fast API Gateway that provides a simple way to aggregate, proxy, and manipulate your backend services. It acts as a middleman that simplifies the management of microservices by reducing the complexity of client-side interactions, enabling developers to focus on building the core features of their applications.
Why Building Plugin for KrakenD is a pain?
There are plenty of plugins available on GitHub to explore, but when you need to build one for a custom requirement, that’s where the real challenges begin. You might create a plugin, only to find it’s not testable because the Go version you used to build the plugin isn’t compatible with the Go version KrakenD is built on. If you’re using an ARM chip, that adds another layer of complexity.
To address these issues, I created an environment using Docker and Docker Compose, complete with KrakenD configurations and all necessary setup components. This includes a dedicated area for building plugins, a build script, and integration tools. The goal is to let you focus on plugin development without worrying about setup hassles — because, let’s be honest, you’ve probably already spent half your life configuring JAVA_HOME (no offense to the Java developers out there).
Simplifying Plugin Development
I have created a GitHub repository that simplifies the process of building custom plugins for the KrakenD API Gateway. The repository is designed to help developers focus on writing their plugin logic without worrying about version compatibility or build complexities.
Repository Structure
Here’s a quick overview of the project structure:
- plugins: Contains subdirectories for each plugin. Each subdirectory corresponds to a different plugin.
- build.sh: A script that automates the compilation of plugins from source code into shared objects (
.so
files). - krakend.json: The main KrakenD configuration file for route setups.
- docker-compose.yml: A Docker Compose file that runs KrakenD with the compiled plugins.
Building Plugins
Before you run the API gateway, you’ll need to build your plugins. The build.sh
script provided in the repository simplifies this process. It doesn’t matter if you’re running on x86 or ARM. Build script works on both!
chmod +x build.sh
./build.sh
Running KrakenD API Gateway
With your plugins built, you’re ready to start the KrakenD API Gateway. Modify the krakend.json
file according to your need. Then use Docker Compose to start the service:
docker-compose up
Customizing Docker Compose
The docker-compose.yml
file is fully customizable. You can tweak KrakenD’s configuration, add environment variables, or integrate additional services to suit your specific needs.