Custom plugin using configmap not working as expected

I’m currently integrating a custom plugin (developed for Kong gateway) into our Kubernetes setup.
The current problem is that I have mounted the CM with the LUA files but, it don’t seem to be picked up.

For setting up this solution I followed an older custom plugins question answer from @traines but without success. I followed the following procedure

kubectl create configmap custom-plugins --from-file=kong-upstream-gateway/ --namespace kong

  1. Add the following to the deployment YAML
        - mountPath: /kong-plugins/kong/plugins
          name: custom-kong-plugins-volume

- name: custom-kong-plugins-volume
          name: custom-plugins
            - key: access.lua
              path: access.lua
            - key: bearer_cache.lua
              path: bearer_cache.lua
            - key: gateway_client.lua
              path: gateway_client.lua
            - key: handler.lua
              path: handler.lua
            - key: json.lua
              path: json.lua
            - key: schema.lua
              path: schema.lua
  1. Recreated the pod, which shows the mount.

but it doesn’t seem to work . How can validate the custom plugin is correctly available ? and where is a good description of enabling custom plugins in a kubernetes ingress controller Kong environment ?

Some advice would be great :slight_smile:

One update since that old post: if you’re using the Helm chart, the mounts/configuration can be set up semi-automatically. That method does have some limitations at present (it doesn’t work well with plugins that have been installed into a custom image or plugins that require external libraries), but works well for simpler plugins.

Loading plugins requires several settings on top of the mounts themselves. Your mounts look fine, though you should be able to simplify the volumeMount (specifying individual files should only be necessary if your ConfigMap keys do not match the intended filenames–creating the ConfigMap from a plugin directory, as you’ve done, should set the correct names by default). For example, the generated volume sections I get from the chart look like:

 - mountPath: /opt/kong/plugins/myplugin
   name: kong-plugin-myplugin
   readOnly: true

 - configMap:
     defaultMode: 420
     name: kong-plugin-test
   name: kong-plugin-myplugin

Kong doesn’t do anything with the mounts unless instructed to, however. You’ll need a few environment variables also, e.g. for the above:

  value: /opt/?.lua;;

  value: bundled,myplugin

You’d use /kong-plugins/?.lua;; for your package path and the plugin name (the directory name under /kong-plugins/kong/plugins) in place of myplugin.

You can alternately mount directly under the standard plugin directory (/usr/local/share/lua/5.1/kong/plugins/) and omit the package path variable.

© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ