【问题标题】:How to add community plugins in kong installed using docker如何在使用 docker 安装的 kong 中添加社区插件
【发布时间】:2020-09-24 08:57:10
【问题描述】:

我们正在尝试安装社区插件 Kong Service Virtualization。由于我对 kong 完全陌生,因此我找不到任何解决方案,其中提供了详细的安装步骤,例如在何处以及如何添加该插件,如何编辑 kong.conf 等。任何人都可以帮助我解决这个问题。 提前致谢。

【问题讨论】:

    标签: docker kong kong-plugin


    【解决方案1】:

    你可以使用luarocks在kong中安装任何插件

    例如这里是一个示例 docker 文件

    FROM kong
    ENV LUA_PATH /usr/local/share/lua/5.1/?.lua;/usr/local/kong-oidc/?.lua;;
    # For lua-cjson
    ENV LUA_CPATH /usr/local/lib/lua/5.1/?.so;;
    
    # Install unzip for luarocks, gcc for lua-cjson
    RUN yum install -y unzip gcc 
    RUN luarocks install luacov
    

    这里是oidc插件的一个例子:https://github.com/nokia/kong-oidc

    我们可以安装插件使用:luarocks install <plugin name>

    构建您自己的自定义 docker 镜像并使用 kong 镜像作为基础 docker 镜像。

    这里是整个示例工作 Dockerfile

    FROM kong:latest  
    USER root
    RUN apk update && apk add git unzip luarocks
    RUN luarocks install kong-oidc  
    USER kong
    

    【讨论】:

    • 尝试使用 Kong Service Virtualization 插件,但在运行新容器 nginx 时出现此错误:[error] init_by_lua 错误:/usr/local/share/lua/5.1/kong/init.lua: 389: [PostgreSQL 错误] 无法检索 PostgreSQL server_version_num: 连接被拒绝
    • 在 ? 上运行 kong 和 postgre sql?
    • 使用 docker 或 docker compose 运行 kong 和 postgre sql?
    • 按照这些步骤进行安装docs.konghq.com/install/docker
    【解决方案2】:

    这是我用来安装 kong-oidc 插件的 Dockerfile 示例:

    FROM kong:2.0.2-alpine
    
    USER root
    
    ENV KONG_PLUGINS=bundled,oidc
    
    # Add libs
    ADD lib/resty/openidc.lua /usr/local/openresty/lualib/resty/openidc.lua
    
    # Add oidc plugin
    ADD plugins/oidc /usr/local/share/lua/5.1/kong/plugins/oidc
    
    # Install dependencies
    RUN luarocks install lua-resty-http
    RUN luarocks install lua-resty-session
    RUN luarocks install lua-resty-jwt 0.2.2
    
    USER kong
    
    

    我正在从我的源代码中添加 oidc 插件,而不是 luarocks,因为存储库未维护,您需要更新一些依赖项才能使其正常工作。

    如果您需要 Kong + OpenID + Keycloak 的功能示例,请查看 this 存储库和 this 文章。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-04
      • 1970-01-01
      • 2020-09-21
      • 2018-10-27
      • 2021-06-21
      • 1970-01-01
      • 2017-02-03
      • 1970-01-01
      相关资源
      最近更新 更多