Kong API Gateway configuration tools for certificate management and cross-environment comparison
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kong_deck_tools-0.2.0.tar.gz.
File metadata
- Download URL: kong_deck_tools-0.2.0.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.27
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2589c61bd74d11ecad8e0b54d64d9086eb167215a98b798bcab2b345156b332e
|
|
| MD5 |
89ae413d12a804fe72dbb692571fb304
|
|
| BLAKE2b-256 |
4b362071e705eaa79f7633dc4430f68c1f49cebe8a03b92c9355c1e43d38f7c6
|
File details
Details for the file kong_deck_tools-0.2.0-py3-none-any.whl.
File metadata
- Download URL: kong_deck_tools-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.27
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d09e072df82fa51a93cbcac286ff8cd6660e3670abd376f9a975ee564213590e
|
|
| MD5 |
2b44c82cd2f578c699c9b38a22cb59c7
|
|
| BLAKE2b-256 |
3b08ecb854b31d9a55c9c74511c65ca5077bfb579b0b5b5f4fc1d4a2f99c6237
|