There are multiple options for using custom plugins in Kubernetes installs. You can either use a custom Docker image or load plugin code from a ConfigMap. I personally recommend using a custom Docker image because:
- It guarantees a specific version of the plugin. Using a ConfigMap can potentially lead to a scenario where the ConfigMap changes and only some Kong pods restart, resulting in inconsistent replica behavior without any clear indication of which version a given replica is running.
- It supports all plugins. The chart ConfigMap loader is not able to install additional libraries (the
dependencies section of a rockspec).
The chart has dedicated configuration for loading plugins via ConfigMaps. Note that Pods must restart to recognize new ConfigMap content: although ConfigMap updates will eventually appear on disk, Kong will not load them into existing processes and will continue using the version available when the Pod started.
To use a custom Docker image, you’ll create a basic Dockerfile based off our image (
FROM kong:2.4) that installs your plugin via LuaRocks (
RUN luarocks install yourplugin).
All documentation from Kong’s plugin development guide and the LuaRocks documentation also applies to Kubernetes installs. Most Kong plugins have similar file structures, so you can review one of our plugin’s rockspecs for a more concrete example.