Lua based Custom Plugin Development best pratices

I wanted to develop a custom plugin based on lua. Currently in my project kong is deployed in production using Helm chart.

Is this good idea to load lua scripts to kubernetes configmap and then use configmap variable names in Helm Chart values.yaml to enable those plugins ? (As kubernetes has limit of each configmap size). Is this the best practice ?

I didn’t find clear documentation to use luarock and rockspec for plugin development and how to use/load in kubernetes cluster. Any suggestion on this ?

Any suggestion which way is better way ?

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.

© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ