Skip to content
Kong Logo | Kong Docs Logo
search
  • We're Hiring!
  • Docs
    • Kong Gateway
    • Kong Konnect
    • Kong Mesh
    • Plugin Hub
    • decK
    • Kubernetes Ingress Controller
    • Insomnia
    • Kuma

    • Docs contribution guidelines
  • Plugin Hub
  • Support
  • Community
  • Kong Academy
Get a Demo Start Free Trial
  • Kong Gateway
  • Kong Konnect
  • Kong Mesh
  • Plugin Hub
  • decK
  • Kubernetes Ingress Controller
  • Insomnia
  • Kuma

  • Docs contribution guidelines
  • 3.3.x (latest)
  • 3.2.x
  • 3.1.x
  • 3.0.x
  • 2.8.x
  • 2.7.x
  • 2.6.x
  • Older Enterprise versions (2.1-2.5)
  • Older OSS versions (2.1-2.5)
  • Archive (pre-2.1)

github-edit-pageEdit this page

report-issueReport an issue

enterprise-switcher-iconSwitch to OSS

On this pageOn this page
  • kong.version
  • kong.version_num
  • kong.configuration
  • kong.db
  • kong.dns
  • kong.worker_events
  • kong.cluster_events
  • kong.cache
Kong Gateway
3.3.x (latest)
  • Home
  • Kong Gateway
  • Plugin Development
  • PDK
  • PDK

PDK

The Plugin Development Kit (PDK) is set of Lua functions and variables that can be used by plugins to implement their own logic.
The PDK is originally released in Kong 0.14.0.

The PDK is guaranteed to be forward-compatible from its 1.0.0 release and onward.

The Plugin Development Kit is accessible from the kong global variable, and various functionalities are namespaced under this table, such as kong.request, kong.log, etc.

kong.version

A human-readable string containing the version number of the currently running node.

Usage

print(kong.version) -- "2.0.0"

kong.version_num

An integral number representing the version number of the currently running node, useful for comparison and feature-existence checks.

Usage

if kong.version_num < 13000 then -- 000.130.00 -> 0.13.0
  -- no support for Routes & Services
end

kong.configuration

A read-only table containing the configuration of the current Kong node, based on the configuration file and environment variables.

See kong.conf.default for details.

Comma-separated lists in the kong.conf file get promoted to arrays of strings in this table.

Usage

print(kong.configuration.prefix) -- "/usr/local/kong"
-- this table is read-only; the following throws an error:
kong.configuration.prefix = "foo"

kong.db

Instance of Kong’s DAO (the kong.db module). Contains accessor objects to various entities.

A more thorough documentation of this DAO and new schema definitions is to be made available in the future.

Usage

kong.db.services:insert()
kong.db.routes:select()

kong.dns

Instance of Kong’s DNS resolver, a client object from the lua-resty-dns-client module.

Note: Usage of this module is currently reserved to the core or to advanced users.

kong.worker_events

Instance of Kong’s IPC module for inter-workers communication from the lua-resty-worker-events module.

Note: Usage of this module is currently reserved to the core or to advanced users.

kong.cluster_events

Instance of Kong’s cluster events module for inter-nodes communication.

Note: Usage of this module is currently reserved to the core or to advanced users.

kong.cache

Instance of Kong’s database caching object, from the kong.cache module.

Note: Usage of this module is currently reserved to the core or to advanced users.

Thank you for your feedback.
Was this page useful?
  • Kong
    THE CLOUD CONNECTIVITY COMPANY

    Kong powers reliable digital connections across APIs, hybrid and multi-cloud environments.

    • Company
    • Customers
    • Events
    • Investors
    • Careers Hiring!
    • Partners
    • Press
    • Contact
  • Products
    • Kong Konnect
    • Kong Gateway
    • Kong Mesh
    • Get Started
    • Pricing
  • Resources
    • eBooks
    • Webinars
    • Briefs
    • Blog
    • API Gateway
    • Microservices
  • Open Source
    • Install Kong Gateway
    • Kong Community
    • Kubernetes Ingress
    • Kuma
    • Insomnia
  • Solutions
    • Decentralize
    • Secure & Govern
    • Create a Dev Platform
    • API Gateway
    • Kubernetes
    • Service Mesh
Star
  • Terms•Privacy
© Kong Inc. 2023