Installing Custom Plugin to Local instance (Windows) built on Docker

Hi All,

I have installed Kong on Windows using a Docker setup. (WSL2 Debian).
Does anyone know how to install Kong custom plugin here ? I am not able to access the kong config file as usual. since the kong instance is installed on Docker.

Thanks

Hi @naveen ,

I presume you already have created custom plugin files and now just want to deploy them to your docker based Kong gateway. If this is so, just follow the below steps:

docker-compose.yml

This is your parent volumes tag

volumes:
  kong-data:

Under your GW image tag:

    image: kong:latest
    volumes: 
      - kong-data:/usr/local/kong

Under your GW environment tag

    environment:
      KONG_LUA_PACKAGE_PATH: "/usr/local/kong/custom/?.lua;;"
      KONG_PLUGINS: "bundled, MY_CUSTOM_PLUGIN"

Note: You can also mention above environment variables through export command once you logged in to the Kong gateway using below mentioned docker exec command

Deploy the gateway

docker-compose up

Copy Files to Gateway

  • Login to your Kong gateway docker container
docker ps -a 
docker exec -it CONTAINER_NAME_OR_ID
cd /usr/local/kong/custom
mkdir MY_CUSTOM_PLUGIN
cd MY_CUSTOM_PLUGIN
  • In this directory you have to put handler.lua and schema.lua

  • You can use vi or any equivalent file editor tool to create above two files and paste your code. Save the files

  • You can also use “volumes: driver: local” feature in docker-compose file to automatically push your custom files from local system to kong gateway while deploying the gateway. But the simplest way is to create just two files mentioned above on the gateway server itself

  • Now restart kong
    kong restart

  • you should be able to see your custom plugin in Kong manager

1 Like

@Sachin_Ghumbre - I am trying to load a custom plugin hello-world to test in my docker container.

I have added the two environment variables KONG_LUA_PACKAGE_PATH and KONG_CUSTOM_PLUGINS

I have mounted my local directory to directory in container under /plugins, but still when I go to localhost:8001, I see only bundled plugins.

Is there something I am missing ?

As per my knowledge CUSTOM_PLUGINs has been deprecated long ago (from 0.14.x).
Use KONG_PLUGINS: “bundled, MY_CUSTOM_PLUGIN” instead.
Once you do this, go to your docker container and check the directory location of custom plugin as directed in above answer.

1 Like

@Sachin_Ghumbre - Thanks for the help. I could see the plugin got loaded when I check in localhost:8001, but would it not show up in Kong Manager ? I was all these time looking into there and wondering it did not load.

@JohnWilliams It should show. Hope you restarted kong gateway “kong restart”

Yes, it does not show up in Kong Manager, but I am able to apply the plugins using Admin APIs and use it in a service and it works fine.

1 Like