Open AlleMartins opened 1 month ago
The plugin server is just an instance that runs your python. In your config it is python_plugin
but also config'd a server named py
.
Two fixes are
KONG_PLUGINSERVER_NAMES: py
KONG_PLUGINSERVER_PY_START_CMD: >-
/usr/local/bin/kong-python-pluginserver
--plugins-directory /usr/local/share/lua/5.1/kong/plugins/python_plugin
--dump
KONG_PLUGINSERVER_PY_QUERY_CMD: >-
/usr/local/bin/kong-python-pluginserver
--plugins-directory /usr/local/share/lua/5.1/kong/plugins/python_plugin
--dump
or
KONG_PLUGINSERVER_NAMES: python_plugin
KONG_PLUGINSERVER_PYTHON_PLUGIN_START_CMD: >-
/usr/local/bin/kong-python-pluginserver
--plugins-directory /usr/local/share/lua/5.1/kong/plugins/python_plugin
--dump
KONG_PLUGINSERVER_PYTHON_PLUGIN_QUERY_CMD: >-
/usr/local/bin/kong-python-pluginserver
--plugins-directory /usr/local/share/lua/5.1/kong/plugins/python_plugin
--dump
Kong will get the plugin name when the pluginserver starts.
After applying your change, therefore changing the name of the embedded server, with py, I get this error: "[error] init_by_lua error: ...al/share/lua/5.1/kong/runloop/plugin_servers/ process.lua:145: Not a plugin info table: kong-1 | /usr/local/bin/kong-python-pluginserver --plugins-directory /usr/local/share/lua/5.1/kong/plugins/python_plugin --dump" I will now attach the important codes of the project, and the logs error (the unspecified settings are like the previous ones said, in the previous commit)
I also add on-board information which may be relevant: my version of kong is the community version, not the enterprise version, I also looked at this link, because it dealt with a similar problem but with the Go programming language: https://support. konghq.com/support/s/article/Golang-custom-plugin-throwing-not-a-plugin-info-table-and-error-loading-plugin-schemas-no-plugin-found, also I changed the name of the my python plugin from "prova_plugin.py" to "python_plugin.py"
Use --dump-all-plugins
instead of --dump
if you are using embedded plugin server (i.e. not dedicated server).
After I apply your change, this "info" appears, the image continues to run, but if I try to access the website (I created a small server with Flask) it doesn't work, so I assume it's an error. The image continues to work, in fact if I do: curl -i GET http://localhost:8001/plugins/enabled it is present, and if I try to activate it it works too
Please ensure you have py-pdk correctly installed. pip3 install kong-pdk
in case it's not installed.
This issue is marked as stale because it has been open for 14 days with no activity.
Is there an existing issue for this?
Kong version (
$ kong version
)Kong 3.6
Current Behavior
Using kong version 3.6, I am encountering when running the kong image "error loading plugin schemas: on plugin: plugin is enabled but not installed". The plugin is implemented with Python 3.12.3, I am using the python plugin present in this link as a plugin: https://github.com/Kong/kong-plugin-py-geocode/tree/main/kong-py-plugins. My docker-compose.yml is as follows:
version: '3.9'
x-kong-config:
&kong-env
KONG_DATABASE: ${KONG_DATABASE:-postgres}
KONG_PG_DATABASE: ${KONG_PG_DATABASE:-kong}
KONG_PG_HOST: db
KONG_PG_USER: ${KONG_PG_USER:-kong}
KONG_PG_PASSWORD_FILE: /run/secrets/kong_postgres_password
volumes: kong_data: {} kong_prefix_vol: driver_opts: type: tmpfs device: tmpfs kong_tmp_vol: driver_opts: type: tmpfs device: tmpfs
networks: kong-net: external: false
services: kong-migrations: image: "${KONG_DOCKER_TAG:-kong:latest}" command: kong migrations bootstrap profiles: [ "database" ] depends_on:
db environment: <<: *kong-env secrets:
kong_postgres_password networks:
kong-net restart: on-failure
kong-migrations-up: image: "${KONG_DOCKER_TAG:-kong:latest}" command: kong migrations up && kong migrations finish profiles: [ "database" ] depends_on:
db environment: <<: *kong-env secrets:
kong_postgres_password networks:
kong-net restart: on-failure
kong: build: context: . dockerfile: Dockerfile.kong
image: "${KONG_DOCKER_TAG:-kong:latest}"
user: "${KONG_USER:-kong}" environment: <<: *kong-env KONG_ADMIN_ACCESS_LOG: /dev/stdout KONG_ADMIN_ERROR_LOG: /dev/stderr KONG_PROXY_LISTEN: "${KONG_PROXY_LISTEN:-0.0.0.0:8000}" KONG_ADMIN_LISTEN: "${KONG_ADMIN_LISTEN:-0.0.0.0:8001}" KONG_ADMIN_GUI_LISTEN: "${KONG_ADMIN_GUI_LISTEN:-0.0.0.0:8002}" KONG_PROXY_ACCESS_LOG: /dev/stdout KONG_PROXY_ERROR_LOG: /dev/stderr KONG_PREFIX: ${KONG_PREFIX:-/var/run/kong} KONG_DECLARATIVE_CONFIG: "/opt/kong/kong.yaml" KONG_LOG_LEVEL: "info" KONG_PLUGINS: "bundled, my_plugin, python_plugin"
KONG_CUSTOM_PLUGINS: python_plugin
KONG_PLUGINSERVER_NAMES: python_plugin KONG_PLUGINSERVER_PY_START_CMD: >- /usr/local/bin/kong-python-pluginserver --plugins-directory /usr/local/share/lua/5.1/kong/plugins/python_plugin --dump KONG_PLUGINSERVER_PY_QUERY_CMD: >- /usr/local/bin/kong-python-pluginserver --plugins-directory /usr/local/share/lua/5.1/kong/plugins/python_plugin --dump secrets:
kong_postgres_password networks:
kong-net ports:
The following two environment variables default to an insecure value (0.0.0.0)
according to the CIS Security test.
"${KONG_INBOUND_PROXY_LISTEN:-0.0.0.0}:8000:8000/tcp"
"${KONG_INBOUND_SSL_PROXY_LISTEN:-0.0.0.0}:8443:8443/tcp"
Making them mandatory but undefined, like so would be backwards-breaking:
- "${KONG_INBOUND_PROXY_LISTEN?Missing inbound proxy host}:8000:8000/tcp"
- "${KONG_INBOUND_SSL_PROXY_LISTEN?Missing inbound proxy ssl host}:8443:8443/tcp"
Alternative is deactivating check 5.13 in the security bench, if we consider Kong's own config to be enough security here
"127.0.0.1:8001:8001/tcp"
"127.0.0.1:8444:8444/tcp"
"127.0.0.1:8002:8002/tcp" healthcheck: test: [ "CMD", "kong", "health" ] interval: 10s timeout: 10s retries: 10 restart: on-failure:5 read_only: true volumes:
kong_prefix_vol:${KONG_PREFIX:-/var/run/kong}
kong_tmp_vol:/tmp
./config:/opt/kong security_opt:
no-new-privileges
db: image: postgres:9.5 profiles: [ "database" ] environment: POSTGRES_DB: ${KONG_PG_DATABASE:-kong} POSTGRES_USER: ${KONG_PG_USER:-kong} POSTGRES_PASSWORD_FILE: /run/secrets/kong_postgres_password secrets:
kong_postgres_password healthcheck: test: [ "CMD", "pg_isready", "-d", "${KONG_PG_DATABASE:-kong}", "-U", "${KONG_PG_USER:-kong}" ] interval: 30s timeout: 30s retries: 3 restart: on-failure stdin_open: true tty: true networks:
kong-net volumes:
kong_data:/var/lib/postgresql/data
secrets: kong_postgres_password: file: ./POSTGRES_PASSWORD
and my dockerfile.kong is as follows:
FROM kong:3.6
USER root
RUN apt-get update && \ apt-get install -y python3 python3-pip python3-dev libffi-dev gcc g++ make && \ PYTHONWARNINGS=ignore pip3 install kong-pdk geopy
COPY ./kong-python-pdk /opt/kong-python-pdk
COPY --chown=kong --chmod=555 ./kong-python-pdk/kong-pluginserver.py /usr/local/bin/kong-python-pluginserver
COPY custom_plugins/python_plugin /usr/local/share/lua/5.1/kong/plugins/python_plugin
COPY custom_plugins/my_plugin /usr/local/share/lua/5.1/kong/plugins/my_plugin
RUN chown -R kong:kong /usr/local/share/lua/5.1/kong/plugins/my_plugin
RUN chown -R kong:kong /usr/local/share/lua/5.1/kong/plugins/python_plugin
USER kong
ENV KONG_PLUGINS="bundled, my_plugin, python_plugin"
EXPOSE 8000 8443 8001 8444
CMD ["kong", "docker-start"]
the name of my embedded server is python_plugin, and to run everything I run the shell command: set KONG_DATABASE=postgres && docker-compose --profile database up --build
but when the command is executed, the previously mentioned error returns. Leaving aside my first plugin written in lua (working), my directory tree is as follows: /usr/local/ ├── bin/ │ └── kong-python-pluginserver # Script per avviare il server del plugin └── share/ └── lua/ └── 5.1/ └── kong/ └── plugins/ ├── python_plugin/ # Directory per il plugin Python │ └── prova_plugin.py # Codice del plugin Python └── my_plugin/ # Directory per altri plugin Lua personalizzati └── handler.lua and schema.lua # Codice del plugin Lua
finally, my kong.yaml is as follows: _format_version: "2.1" _transform: true What do I need to change? From the documentation provided, it appears that kong cannot find my python code, but although everything seems fine, it still doesn't work (https://support.konghq.com/support/s/article/plugin-is-enabled- but-not-installed)
Expected Behavior
No response
Steps To Reproduce
Anything else?
No response