Skip to main content

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:

  1. Extract certificates from Kong configurations into separate files, allowing templates to be safely committed to git while keeping sensitive certificate data separate
  2. 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 certificate values file:

kong-templatize config.yaml

Input: config.yaml (full Kong configuration with certificates)

Output:

  • config.tmpl.yaml - Template with Helm-style placeholders for certificates
  • config.certs.values.yaml - Extracted certificate values (name, cert, key)

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

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


Download files

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

Source Distribution

kong_deck_tools-0.1.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kong_deck_tools-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file kong_deck_tools-0.1.0.tar.gz.

File metadata

  • Download URL: kong_deck_tools-0.1.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.27

File hashes

Hashes for kong_deck_tools-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9701302aeae7b48aa04e2329c1dee2c322f8a4b156d9397da5a5acf3457b20df
MD5 d3d3872db19103da9b6799482f993de3
BLAKE2b-256 cbdbee64f0702eabba1dfc9a8f5237515fa0f96524dc45a99783ae5d819af172

See more details on using hashes here.

File details

Details for the file kong_deck_tools-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for kong_deck_tools-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 138d72ce18820bcfd54e4675cf3f8c287369cd0ef2e0ea46e132d938dc558a81
MD5 459337257c2b778732eefe984f46d804
BLAKE2b-256 7efea918dc57139dacc28a5ab3ce2941a604e052af711a8818832f972fc9b803

See more details on using hashes here.

Supported by

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