Custom plugins can be added to the ingress controller via volume mounts and environment variable configuration. Note that these need to be added to both the kong Deployment and the ingress-kong Deployment, as the ingress controller uses a split deployment with separate Kong nodes for the admin API and proxy.
You’ll need to first create a configMap to hold your plugin source with something like kubectl create configmap custom-plugins --from-file=/path/to/kong-plugin-hello/ --namespace kong .
After, the volume configuration in the Kong deployment will look something like:
image: kong:1.0.2-centos
volumeMounts:
- name: custom-plugin-vol
mountPath: /kong-plugins/kong/plugins/
env:
- name: KONG_LUA_PACKAGE_PATH
value: "/kong-plugins/?.lua;;"
- name: KONG_CUSTOM_PLUGINS
value: hello-world
volumes:
- name: custom-plugin-vol
configMap:
name: custom-plugins
items:
- key: handler.lua
path: hello-world/handler.lua
- key: schema.lua
path: hello-world/schema.lua
With that deployed, you can add Ingress objects normally, with annotations to load the plugin and specify configuration as you would with any standard plugin.
Note that there are some caveats to updating ConfigMaps that you’ll need to take into account pending Kubernetes feature requests:
You can alternately build a custom Docker image, starting from one of the standard Kong images and copying the plugin files over. The environment variables should still be added, but the volumeMounts/configMaps can be removed.