Skip to main content

Kong PDK for Python and Plugin Server

Project description

kong-python-pluginserver

PyPI version

Plugin server and PDK (Plugin Development Kit) for Python language support in Kong.

Requires Kong >= 2.3.0.

Install the plugin server

pip3 install kong-pdk

Usage

usage: kong-pluginserver [-h] [-p prefix] [-v] [--version]
                         [--socket-name SOCKET_NAME] [-m | -g] -d directory
                         [--dump-plugin-info name] [--dump-all-plugins]

Kong Python Plugin Server.

optional arguments:
  -h, --help            show this help message and exit
  -p prefix, --kong-prefix prefix, -kong-prefix prefix
                        Unix domain socket path to listen
  -v, --verbose         Turn on verbose logging
  --version, -version   show program's version number and exit
  --socket-name SOCKET_NAME
                        socket name to listen on
  -m, --multiprocessing
                        Enable multiprocessing
  -g, --gevent          Enable gevent
  -d directory, --plugins-directory directory, -plugins-directory directory
                        Plugins directory
  --dump-plugin-info name, -dump-plugin-info name
                        Dump specific plugin info into stdout
  --dump-all-plugins, -dump-all-plugins
                        Dump specific plugin info into stdout

Configure Kong

Add the following line into kong.conf:

plugins=bundled,py-hello,py-image
pluginserver_names=go, py
pluginserver_py_socket=/usr/local/kong/python_pluginserver.sock
pluginserver_py_start_cmd=/usr/local/bin/kong-python-pluginserver -d /dir/to/kong-python-pdk/examples
pluginserver_py_query_cmd=/usr/local/bin/kong-python-pluginserver -d /dir/to/kong-python-pdk/examples --dump-all-plugins

For example, to test examples, clone kong-python-pdk to /dir/to/kong-python-pdk.

To use seperate instance for each plugin, use:

plugins=bundled,py-hello,py-image
pluginserver_names=go, py-hello, py-image

pluginserver_py_hello_socket=/usr/local/kong/py_hello.sock
pluginserver_py_hello_start_cmd=/dir/to/kong-python-pdk/examples/py-hello.py
pluginserver_py_hello_query_cmd=/dir/to/kong-python-pdk/examples/py-hello.py -d

pluginserver_py_image_socket=/usr/local/kong/py_image.sock
pluginserver_py_image_start_cmd=/dir/to/kong-python-pdk/examples/py-image.py
pluginserver_py_image_query_cmd=/dir/to/kong-python-pdk/examples/py-image.py -d

Enable the plugin

Same step as it's a Lua plugin.

Notes

  • All PDK API supported by Go Plugin Server is supported.
  • If your plugin is CPU intensive, consider using multiprocessing mode (-m flag) or run the plugin instance in a seperate process (examples/py-hello.py as an example) to distribute workloads to multicore.
  • If your plugins are I/O intensive, considering using gevent mode (-g flag) and use gevent libraries in the plugin.

TODO

  • Tests
  • Hot reload

Unreleased

0.2.1 - 2021-02-24

feat

fix

  • disable gevent in multiprocessing and make it optional 5b6fb68
  • chmod+x on examples 1f5905d

0.2.0 - 2021-02-22

feat

  • exit server if parent is dead 0ee2183
  • embed server in plugin af55deb

fix

  • sync with Kong 2.3 update d42de7e

refactor

  • rename kong_pluginserver to kong_pdk e802627

0.1.2 - 2020-02-21

fix

0.1.1 - 2020-02-20

0.1.0 - 2020-01-03

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kong_pdk-0.21.tar.gz (12.7 kB view details)

Uploaded Source

Built Distributions

kong_pdk-0.21-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

kong_pdk-0.21-py2-none-any.whl (22.0 kB view details)

Uploaded Python 2

File details

Details for the file kong_pdk-0.21.tar.gz.

File metadata

  • Download URL: kong_pdk-0.21.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.7

File hashes

Hashes for kong_pdk-0.21.tar.gz
Algorithm Hash digest
SHA256 6bbde69f4ece73c05df5b0dba1bf72658fd03a5e7889bc85741e5f295764949a
MD5 560739603220143e5efb1745654a964a
BLAKE2b-256 506af5c76754c0af49a54d8bd46312e1be149a8a527eaa58a8dab7397c70d6d8

See more details on using hashes here.

File details

Details for the file kong_pdk-0.21-py3-none-any.whl.

File metadata

  • Download URL: kong_pdk-0.21-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.7

File hashes

Hashes for kong_pdk-0.21-py3-none-any.whl
Algorithm Hash digest
SHA256 9116fe6eced77a81410d482c62a6ed29ef405f14897c357aac2e01634479ab00
MD5 f52cddced5383952c3cb5471ec1a9aad
BLAKE2b-256 9abcf89d442efdbefae60e4b96b982513eee860d2980af2ffe696aeed9b1dd7e

See more details on using hashes here.

File details

Details for the file kong_pdk-0.21-py2-none-any.whl.

File metadata

  • Download URL: kong_pdk-0.21-py2-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.7

File hashes

Hashes for kong_pdk-0.21-py2-none-any.whl
Algorithm Hash digest
SHA256 c77830be772b9cc2415736eb9378d07a163fdd8afd14a895da7aea7114845eb7
MD5 8a107ddd0693e391516f665457eb3e6f
BLAKE2b-256 d09215c4009c182a43f0432c345993259f6278da5132e0af2762b43ed3959f2c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page