Is there a way to setup a custom plugin for kong (I’m trying to use the nokia-oidc plugin, https://github.com/nokia/kong-oidc) when an ingress is created for the Kong-Ingress-Controller? Currently my ingress yml file looks like this:
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:
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.
Also a side node that when you applying a plugin resource in Ingress Controller, you will need to specify the plugin field as well. The metadata.name field is used to attach the plugin resource to a service/route/consumer resource, and it doesn’t equal to name in Kong Admin API. The plugin field specifies the actual plugin you want to create, in your case it will be oidc.
I had already went down the path of building a custom docker image with the oidc plugin built in.
RUN luarocks install kong-oidc
RUN sh -c “echo ‘plugins = bundled,oidc’ >> /etc/kong/kong.conf”
It looks like the main thing I was missing is the environment variables in the yaml file. Would I need the KONG_LUA_PACKAGE_PATH value or is KONG_CUSTOM_PLUGINS sufficient?
Any update on your progress? I’m trying to do exactly this and still not quite there. I have a custom docker image but when trying to start the image it is looking for DB config and I want to run in db-less mode.
You can easily setup Custom plugins with Kong Ingress Controller.
Here is a handy guide to setup plugins via COnfigMaps:
Kong and the Ingress Controller do not differentiate between a plugin that is bundled with Kong and a plugin that is installed by a user. They are exactly the same. The only challenge is to ensure that you have to install the plugin in the file-system and configure plugins property.
After updating the YAML finally custom pluing get install but after that got next issue. Now same POD, Deployment and Replicaset throwing “CrashloopOff”. After checking the log of the pod we got following error.