kong-deck-tools
Kong API Gateway configuration tools for certificate management and cross-environment comparison.
Overview
This package provides CLI tools for managing Kong API Gateway configurations:
- Extract sensitive cryptographic material (certificates, CA certificates, and keys) from Kong configurations into separate files, allowing templates to be safely committed to git while keeping sensitive data separate
- Enforce consistent key ordering across all configurations, making it easy to compare configurations across different environments (local, staging, production)
Installation
pip install kong-deck-tools
Usage
kong-templatize
Splits a Kong configuration into a template and a values file:
kong-templatize config.yaml
Input: config.yaml (full Kong configuration with certificates and keys)
Output:
config.tmpl.yaml- Template with Helm-style placeholders for sensitive dataconfig.certs.values.yaml- Extracted values (certificates, CA certificates, and keys)
Extracts the following sensitive fields:
certificates[].certandcertificates[].key— keyed by SNI nameca_certificates[].cert— keyed by IDkeys[].pem.private_key,keys[].pem.public_key, andkeys[].jwk— keyed by kid
The script also prettifies the template by reordering YAML keys for consistency and readability.
kong-hydrate
Reconstructs a full Kong configuration from template and values:
kong-hydrate config.tmpl.yaml
Input: config.tmpl.yaml (template file; values file config.certs.values.yaml is derived automatically)
Output: config.rendered.yaml (complete Kong configuration)
Workflow with Kong deck
# 1. Export current Kong configuration
deck gateway dump -o config.yaml
# 2. Extract certificates and create template
kong-templatize config.yaml
# 3. Commit template to git (certificates stay separate)
git add config.tmpl.yaml
git commit -m "Update Kong configuration"
# 4. Before deploying, hydrate the template with certificates
kong-hydrate config.tmpl.yaml
# 5. Compare with current Kong state
deck gateway diff config.rendered.yaml
# 6. Apply changes
deck gateway sync config.rendered.yaml
Key Ordering
The kong-templatize command enforces consistent key ordering to make configs:
- Human-readable: Important fields (name, enabled) appear first
- Diff-friendly: Consistent ordering reduces noise in git diffs
- Hierarchical: Configuration objects (routes, plugins) appear after their properties
Key ordering by entity type:
- Plugins: name -> enabled -> config -> protocols -> tags
- Services: name -> enabled -> host -> port -> protocol -> timeouts -> tags -> plugins -> routes
- Routes: name -> hosts -> paths -> protocols -> strip_path -> preserve_host -> ... -> plugins
- Upstreams: name -> algorithm -> slots -> hash_* -> tags -> healthchecks -> targets
- Consumers: username -> custom_id -> tags
- CA Certificates: id -> cert -> cert_digest -> tags
- Keys: name -> kid -> set -> pem -> jwk -> tags
Requirements
- Python 3.8+
- Kong deck CLI (for dumping/syncing configurations)
Development
Install in development mode
git clone https://github.com/michaeltan/kong-deck-tools.git
cd kong-deck-tools
pip install -e .
Publishing to PyPI
# Install uv (if not already installed)
brew install uv
# Build the package
uv build
# Upload to PyPI
uv publish
License
MIT
Metadata
Release files for kong-deck-tools 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| kong_deck_tools-0.2.0.tar.gz | 9.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kong_deck_tools-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.1 kB
Release files / kong_deck_tools-0.2.0.tar.gz
| Download URL | kong_deck_tools-0.2.0.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2589c61bd74d11ecad8e0b54d64d9086eb167215a98b798bcab2b345156b332e
|
|
BLAKE2b-256 checksum How to use checksums |
4b362071e705eaa79f7633dc4430f68c1f49cebe8a03b92c9355c1e43d38f7c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.27
|
Release files / kong_deck_tools-0.2.0-py3-none-any.whl
| Download URL | kong_deck_tools-0.2.0-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d09e072df82fa51a93cbcac286ff8cd6660e3670abd376f9a975ee564213590e
|
|
BLAKE2b-256 checksum How to use checksums |
3b08ecb854b31d9a55c9c74511c65ca5077bfb579b0b5b5f4fc1d4a2f99c6237
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.27
|
Security for kong-deck-tools 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.