Kong Plugin with Dependencies in Kubernetes

Hi,

I have a Plugin I’d like to install in my Kong instance which is running on Kubernetes.
After reading this: https://github.com/Kong/kubernetes-ingress-controller/blob/master/docs/guides/setting-up-custom-plugins.md
the Plugin was starting to load by Kong. Unfortunately it breaks then, because I have a dependency to resty.openidc which is not installed.

So how do I install those missing dependencies?
I tried to install the dependency as a Kong Plugin, but it’s missing a handler.lua and breaks because of this.
I tried to put the dependency in a subdirectory and adjusted the require() calls, but resty.openidc itself has also dependencies, which would also have to be adjusted.

Someone mentioned, that it would be possible with a InitContainer. How would that work, when my installation is done with Helm?

Thank you!
Balomueller

Yep–this is kind of a necessary limitation between what ConfigMaps offer and what installing plugins entails when it has dependencies.

There is the subdirectory loader in the Helm chart, but it sounds like you’ve already tried that without success.

If that doesn’t provide a good way for you to include all requirements, you’ll probably want to look at creating a custom Kong image that installs the plugin(s) via LuaRocks. Since LuaRocks has its own Lua-aware dependency management, it’s able to install plugins and their dependencies more intelligently than the ConfigMap-based loader. Building the custom image will require that you create a Dockerfile that’s something along the lines of

FROM kong:2.0.4

RUN ["luarocks", "install", "pluginname"]

The resulting image will include both the plugin and its dependencies in the correct location, and you can load it into a private registry for use in your Kubernetes cluster.

The ConfigMap-based loader is useful for simpler plugins that only require their own code (and libraries that are already in the image by default)–more complex plugins with other external dependencies can sometimes load through the ConfigMap loader, but will often be easier to handle with custom images. I’ll note down that we should update our docs to cover both methods.


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ