user1863661
user1863661

Reputation: 31

Kong refuses to recognise custom plugin as enabled

I was developing a Custom plugin for Kong.

To start off I followed guidelines listed in this tutorial

http://streamdata.io/blog/developing-an-helloworld-kong-plugin/

Few changes that I made along the way were changing dependency in the rockspec file for "lrexlib-pcre" from version 2.8.0-1 to 2.7.2-1 due to compilation problems that I faced with 2.8.0-1 version. Please note that I am working in the next branch. The master branch has version 2.7.2-1 listed.

The tutorial assumes Kong version 0.4.2-1 while I am working with Kong version 0.5.2-1.

I have listed my plugin in kong.yml. Last listed is helloworld plugin

    plugins_available:
  - ssl
  - jwt
  - acl
  - cors
  - oauth2
  - tcp-log
  - udp-log
  - file-log
  - http-log
  - key-auth
  - hmac-auth
  - basic-auth
  - ip-restriction
  - mashape-analytics
  - request-transformer
  - response-transformer
  - request-size-limiting
  - rate-limiting
  - response-ratelimiting
  - helloworld

I have listed the helloworld files in rockspec file at the last.

["kong.plugins.helloworld.handler"] = "kong/plugins/helloworld/handler.lua", ["kong.plugins.helloworld.access"] = "kong/plugins/helloworld/access.lua", ["kong.plugins.helloworld.schema"] = "kong/plugins/helloworld/schema.lua"

Compilation is successful but kong refuses to list helloworld plugin as available in the node. All other builtin plugins are shown as available in the server

I tried enabling the plugin anyway with mock api. It doesn't work as expected and trying to restart kong lists error

nginx: [error] [lua] init_by_lua:5: Startup error: /usr/local/share/lua/5.1/kong.lua:82: You are using a plugin that has not been enabled in the configuration: helloworld [INFO] dnsmasq stopped [ERR] Could not start Kong

I know there were some breaking changes introduced in Kong version 0.5. I followed the changelog, but I found nothing that would help.

Am i missing a setting a configuration somewhere?

Any help would be appreciated.

Upvotes: 3

Views: 2651

Answers (2)

Vikas Kumar
Vikas Kumar

Reputation: 71

I fixed this issue by adding things in custom_plugins and lua_package_path.

Here are the steps to enable and use custom plugin in kong Env.

1 - Add custom plugin name in --- custom_plugins = hello-world

2 - Install hello-world plugin by using following steps ---

If you have source code of your plugin then move into it and execute the command --- "luarocks make"

it will install your plugin.

now you have to execute a command "make install-dev" make sure your plugin have makefile like as --

enter image description here

Once you execute this command "make install-dev". it will create lua file at a location something like that -

/your-plugin-path/lua_modules/share/lua/5.1/kong/plugins/your-plugin-name/?.lua

just copy this path and add it into the kong configuration file in lua_package_path

Something like that --

lua_package_path=/your-plugin-path/lua_modules/share/lua/5.1/kong/plugins/your-plugin-name/?.lua

Now you done your job.

Just start kong -- kong start --vv

You will see that the plugin loaded into kong plugin env.

@Enjoy

Upvotes: 0

Sig
Sig

Reputation: 5188

Try the following in your kong.yml:

custom_plugins:
  - helloworld

Upvotes: 0

Related Questions