1

I have created one custom kong plugin and trying to deploy it locally. Trying with Luarocks, Pongo and Manually... but some how now able to make it.

Sharing steps what I am following below.

Command

luarocks make 

Logs

kong-check-x-header 1.0-1 depends on lua ~> 5.1 (5.1-1 provided by VM) kong-check-x-header 1.0-1 is now installed in /usr/local/Cellar/openresty@1.19.3.2/1.19.3.2/luarocks (license: Apache 2.0)

Command

luarocks pack kong-check-x-header 1.0-1

logs

Packed: /Users/jaikratsinghtariyal/Sandbox/kong-check-x-header/kong-check-x-header-1.0-1.all.rock

Command

luarocks install kong-check-x-header-1.0-1.all.rock

logs

kong-check-x-header 1.0-1 depends on lua ~> 5.1 (5.1-1 provided by VM)

Error: /usr/local/Cellar/openresty@1.19.3.2/1.19.3.2/luarocks/lib/luarocks/rocks-5.1/kong-check-x-header/1.0-1/lua/kong/plugins/kong-check-x-header/schema.lua: No such file or directory

Been quite some days...struggling with this... need some assistant here pls.

GITHUB - https://github.com/jaikratsinghtariyal/kong-check-x-header

UPDATE After Comment

Commands fired in below order.

  • pongo pack

logs -

Creating kong-pongo_kong_run ... done

kong-plugin-check-x-header 1.0-1 depends on lua ~> 5.1 (5.1-1 provided by VM)
Stopping after installing dependencies for kong-plugin-check-x-header 1.0-1

Kong version: 2.5.0

kong-plugin-check-x-header 1.0-1 depends on lua ~> 5.1 (5.1-1 provided by VM)
kong-plugin-check-x-header 1.0-1 is now installed in /usr/local (license: Apache 2.0)

Packed: /kong-plugin/kong-plugin-check-x-header-1.0-1.all.rock

`

  • pongo shell
  • luarocks install /kong-plugin/kong-plugin-check-x-header-1.0-1.all.rock

Logs:-

kong-plugin-check-x-header 1.0-1 depends on lua ~> 5.1 (5.1-1 provided by VM) 
kong-plugin-check-x-header 1.0-1 is now installed in /usr/local (license: Apache 2.0)
  • export KONG_PLUGINS=bundled,kong-plugin-check-x-header (shall I mention kong-plugin-check-x-header or check-x-header... Tried both actually its failing in both but error are more promising with check-x-header)
  • kong migrations bootstrap
  • kong start

All command except kong start are working.

Logs -

Error: 
/usr/local/share/lua/5.1/kong/cmd/start.lua:75: /usr/local/share/lua/5.1/kong/cmd/start.lua:64: nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:515: error loading plugin schemas: on plugin 'kong-plugin-check-x-header': kong-plugin-check-x-header plugin is enabled but not installed;
no plugin found
stack traceback:
    [C]: in function 'assert'
    /usr/local/share/lua/5.1/kong/init.lua:515: in function 'init'
    init_by_lua:3: in main chunk

stack traceback:
    [C]: in function 'error'
    /usr/local/share/lua/5.1/kong/cmd/start.lua:75: in function 'cmd_exec'
    /usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:88>
    [C]: in function 'xpcall'
    /usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:45>
    /kong/bin/kong:9: in function 'file_gen'
    init_worker_by_lua:47: in function <init_worker_by_lua:45>
    [C]: in function 'xpcall'
    init_worker_by_lua:54: in function <init_worker_by_lua:52>
Jaikrat
  • 1,124
  • 3
  • 24
  • 45

1 Answers1

1

First to use pongo you have to respect the file path and plugins name

kong-check-x-header => kong-plugin-check-x-header

then you should put your files in the right directory kong/plugins/check-x-header/

you have kong-check-header-x instead of check-x-header in a spec file.

I think you should use linter like pongo lint to detect issue for example X-Auth-Token cannot be used as key you should prefer X_Auth_Token

Ôrel
  • 7,044
  • 3
  • 27
  • 46
  • Right, so I did the changes and command `luarocks make` is failing with `Error: Filename './kong-check-x-header-1.0-1._rockspec' does not look like a rockspec.` – Jaikrat Sep 07 '21 at 12:14
  • 1
    I don't understand, the file name is `kong-plugin-check-x-header-1.0-1.rockspec` Try to use pongo I think it will be easier – Ôrel Sep 07 '21 at 14:42