Kong-返回的自定义插件:自定义插件已启用但未安装;

时间:2019-11-19 23:35:14

标签: docker dockerfile kong

我有一个正在使用内容的Dockerfile运行的Kong实例:

FROM kong:1.4.0

WORKDIR /files
COPY plugins kong/plugins
ENV KONG_LOG_LEVEL=debug
ENV KONG_PLUGINS custom-plugin
ENV KONG_LUA_PACKAGE_PATH /files/?.lua;;

但是,在docker run上,它将返回

error loading plugin schemas: on plugin 'custom-plugin': custom-plugin plugin is enabled but not installed;

module 'kong.plugins.custom-plugin.handler' not found:No LuaRocks module found for kong.plugins.custom-plugin

任何人都可以帮助解决此问题吗?

2 个答案:

答案 0 :(得分:0)

看看Kong/kong-plugin-zipkin issue 5中的一条指令(另一个依赖于kong.plugins.custom-plugin.handler的插件)是否对kong.plugins.custom-plugin.handler本身有效。

  

要点是该插件应可在磁盘上用于Kong,并已添加到custom_plugins配置属性中。

     

您可以通过多种方式实现此目标:

           

不要忘记,您还可以使用环境变量指定configure Kong,因此使用-e KONG_CUSTOM_PLUGINS=my-custom-plugin也可以。

     

该插件也必须位于LUA_PATH中(类似于PATH,但适用于Lua模块)。

     

因此,简而言之,一种可能的解决方案是使用卷和环境变量:

     
      
  • 安装插件的代码:-v /path/to/my-custom-plugin:/etc/kong/plugins/my-custom-plugin
  •   
  • 将包含自定义插件的目录添加到LUA_PATH-e KONG_LUA_PACKAGE_PATH=/etc/?.lua(Kong需要kong.plugins.custom-plugin.handler,它转换为/etc/kong/plugins/my-custom-plugin/handler.lua
  •   
  • 指示Kong使用以下方式加载插件:-e KONG_CUSTOM_PLUGINS=my-custom-plugin
  •   

首先,请检查是否是KONG_LUA_PATH问题,例如Kong/kong issue 3394

这是关于插件迁移的,但在这里也可能会产生影响。

  

作为一种短期解决方案,您应该将LUA_PATH环境变量设置为指向自定义插件的安装路径
  (而不是lua_package_pathkong.conf中的KONG_LUA_PACKAGE_PATH)。

     

例如我刚刚搬家:

export KONG_LUA_PACKAGE_PATH="/path/to/some-custom-plugin/?.lua;;"
     

收件人:

export LUA_PATH="/path/to/some-custom-plugin/?.lua;$LUA_PATH"
     

再次运行kong migrations up,成功运行了插件的迁移。

     

这是因为lua_package_path仅用于运行时Kong(在nginx中),而CLI并未考虑(kong migrations命令)

     

如果我只是在lua_package_path中评论了kong.conf,并按照您的说明导出了LUA_PATH,它就开始给我这个错误:

./kong:3: module 'luarocks.loader' not found:
     

我用来执行kong迁移的shell甚至从未设置过LUA_PATH。如果尚未在外壳中设置luarocks,则LUA_PATH会在内部创建LUA_PATH

     

因此,我必须执行的另一步骤是通过运行“ luarocks path”命令获取内部设置的当前LUA_PATH,然后获取结果,并将我的自定义登录插件路径附加到然后导出该public Animator sceneAnimator; void Start() { for (int i = 0; i < Display.displays.Length; i++) { Display.displays[i].Activate(); } } private void Update() { HotKeys(); } private void HotKeys() { if (Input.GetKeyDown(KeyCode.F1)) { StartCoroutine(DDIR()); } if (Input.GetKeyDown(KeyCode.F2)) { StartCoroutine(BILD()); } if (Input.GetKeyDown(KeyCode.F3)) { StartCoroutine(SORT()); } } public IEnumerator DDIR() { sceneAnimator.SetTrigger("Out"); yield return new WaitForSeconds(0.5f); SceneManager.LoadScene("DDIR"); } public IEnumerator BILD() { sceneAnimator.SetTrigger("Out"); yield return new WaitForSeconds(0.5f); SceneManager.LoadScene("BILD"); } public IEnumerator SORT() { sceneAnimator.SetTrigger("Out"); yield return new WaitForSeconds(0.5f); SceneManager.LoadScene("SORT"); } 使其生效。

同样,即使您当前的问题与迁移无关,这些变量之一也可能会有所帮助。

答案 1 :(得分:0)

签出这些资源:

来自香港的错误报告: https://github.com/Kong/kong/issues/4696

I don't think it's the luarocks' problem
Indeed, I installed kong in docker whose image is built by a dockerfile.
In my docker file, I went into the folder which store the custom plugins,and then traverse and luarocks make them by shell.It looks like:

#install private plugins
cd APIGPlugins

for dir in `ls`; do
    if [ -d $dir ]; then
      cd $dir;
      luarocks make;
      cd ../;
    fi
done
and then, I run the docker images for a container by the directive:

sudo docker run -d --name kong \
    -e "KONG_DATABASE=off" \
    -e "KONG_DECLARATIVE_CONFIG=/etc/kong/kong.yml" \
    -e "KONG_PLUGINS=apig-response-transform" \
    -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \
    -p 8000:8000 \
    -p 8443:8443 \
    -p 8001:8001 \
    -p 8444:8444 \
    kong-plugin:v4
As u see, I set the kong plugin by the docker run env variable parameter for enable the plugin instead of setting in the kong.conf.
The logs were generated by directive of docker logs "container ID"
It works when I tried to install another custom plugin in this way,but not work when install the custom plugin I described before