Kong Version 3.5
I'm currently developing a custom lua plugin that needs to be deployed via helm & a config map. We are running kong in dbless mode.
I created a config map
apiVersion: v1
kind: ConfigMap
metadata:
name: kong-plugin-test-plugin
labels:
{{- include "test.labels" . | nindent 4 }}
data:
handler.lua: |-
{{ .Files.Get "plugins/test-plugin/handler.lua" | indent 4}}
schema.lua: |-
{{ .Files.Get "plugins/test-plugin/schema.lua" | indent 4}}
The file contents are
handler.lua
local TestPlugin = {}
TestPlugin.PRIORITY = 10
TestPlugin.VERSION = "1.0.0"
function TestPlugin:header_filter(conf)
kong.response.set_header("TEST-HEADER", conf.header_value)
end
return TestPlugin
schema.lua
return {
name = "test-plugin",
fields = {
{
config = {
type = "record",
fields = {
{ header_value = { type = "string", default = "roar", }, },
},
},
},
},
}
I included it it my values.yaml
plugins:
configMaps:
- name: kong-plugin-test-plugin
pluginName: test-plugin
and its also mapped with these values to certain routes in my kong.config (kong.yml)
- name: test-plugin
config:
header_value: 'THIS-IS-A-TEST'
I checked the helm renderings and everything looks correct to me. However if I deploy it via helm, the container goes into an error state after logging the following
[error] 1#0: init_by_lua error: ...are/lua/5.1/kong/db/schema/others/declarative_config.lua:654: table index is nil │
│ ack traceback: │
│ ...are/lua/5.1/kong/db/schema/others/declarative_config.lua:654: in function 'populate_ids_for_validation' │
│ ...are/lua/5.1/kong/db/schema/others/declarative_config.lua:639: in function 'populate_ids_for_validation' │
│ ...are/lua/5.1/kong/db/schema/others/declarative_config.lua:759: in function 'flatten' │
│ /usr/local/share/lua/5.1/kong/db/declarative/init.lua:224: in function 'parse_file' │
│ /usr/local/share/lua/5.1/kong/init.lua:533: in function 'parse_declarative_config' │
│ /usr/local/share/lua/5.1/kong/init.lua:715: in function 'init' │
│ init_by_lua(nginx-kong.conf:47):3: in main chunk │
│ inx: [error] init_by_lua error: ...are/lua/5.1/kong/db/schema/others/declarative_config.lua:654: table index is nil │
│ ack traceback: │
│ ...are/lua/5.1/kong/db/schema/others/declarative_config.lua:654: in function 'populate_ids_for_validation' │
│ ...are/lua/5.1/kong/db/schema/others/declarative_config.lua:639: in function 'populate_ids_for_validation' │
│ ...are/lua/5.1/kong/db/schema/others/declarative_config.lua:759: in function 'flatten' │
│ /usr/local/share/lua/5.1/kong/db/declarative/init.lua:224: in function 'parse_file' │
│ /usr/local/share/lua/5.1/kong/init.lua:533: in function 'parse_declarative_config' │
│ /usr/local/share/lua/5.1/kong/init.lua:715: in function 'init' │
│ init_by_lua(nginx-kong.conf:47):3: in main chunk
I have no clue if I'm doing something wrong or if kong is an issue and have found nothing about this error "declarative_config.lua:654: table index is nil" I tried the same with an existing open source kong plugin (by copying it - and renaming it) from this repo but had the exact same error. I would have expected that the plugin simply works as its really basic and should just jumpstart the development.