Tool to generate the spec template for kong with support of different plguins. Different plugins at service/route level are needed to setup our service on kong.This can be used to generate a template and playaround with it.
Now you can generate template with plugins at global, service and route level.You take the template and extend it for other routes/services.
- key-auth
- cors
- request-transformer-advanced
- rate-limiting-advanced
- exit-transformer
- pre-function
- acl
- Generate the template with plugins at service,route or global level
- Summarise the kong-spec by loading the existing kong-spec and visualise them
- Kong Spec from JSON to YAML and vice-versa
- Handle plugin priority in visualisation via graphviz
brew tap rag594/tap
brew install knox
knox convert --to-format <yaml or json> --input <input-file>
brew install graphviz
knox visualise --spec <spec-file> --output <output-file>
dot -Tsvg -O <dot-output>
![Screenshot 2023-10-21 at 2 49 59 AM](https://private-user-images.githubusercontent.com/8286518/277054398-708cc159-223c-471c-a23d-29395d9f16c4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA0NTI5NjUsIm5iZiI6MTcyMDQ1MjY2NSwicGF0aCI6Ii84Mjg2NTE4LzI3NzA1NDM5OC03MDhjYzE1OS0yMjNjLTQ3MWMtYTIzZC0yOTM5NWQ5ZjE2YzQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcwOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MDhUMTUzMTA1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZDRjNTZlODU4YjA4NTI4NjMzOGRhZDUyYjk3OWZkMzY3YWQ3NjdhYmU0ZGYxOTZlOWE4YTFjMTdlMTZhZTVlNCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.QZB7cLYRuVqU7JdpM6y3868E1fGvfx3BijRCnLMmmcw)
foo@bar:~$ knox generate --help
NAME:
CLI for generating kong-spec template generate - generate kong-spec template
USAGE:
CLI for generating kong-spec template generate [command options] [arguments...]
OPTIONS:
--service-plugins value add service-plugins in comma-separated format. Example --service-plugins key-auth,cors
--route-plugins value add route-plugins in comma-separated format. Example --route-plugins key-auth,cors
--global-plugins value add global-plugins in comma-separated format. Example --global-plugins key-auth,cors
--help, -h show help
foo@bar:~$ knox visualise --help
NAME:
CLI for generating/visualising kong-spec visualise - generate the graphviz
USAGE:
CLI for generating/visualising kong-spec visualise [command options] [arguments...]
OPTIONS:
visualise
--output value provide your output file using --output <file-path>
--spec value load the file using --spec <file-path>
foo@bar:~$ knox convert --help
NAME:
CLI for generating/visualising kong-spec and convert - convert to JSON or YAML
USAGE:
CLI for generating/visualising kong-spec convert [command options] [arguments...]
OPTIONS:
converter
--input value provide your input file using --input <file-path>
--to-format value provide the format using --to-format <yaml or json>
foo@bar:~$ knox generate --service-plugins "key-auth"
_format_version: "3.0"
_info:
defaults: {}
select_tags: []
services:
- name: DefaultService
host: xyz.com
port: 80
protocol: ""
path: /
retries: 0
enabled: true
read_timeout: 60000
connect_timeout: 60000
write_timeout: 60000
plugin:
- config:
key_names:
- apiKey
hide_credentials: true
key_in_header: true
key_in_query: false
key_in_body: false
run_on_preflight: false
enabled: true
name: key-auth
protocols:
- http
- https
routes:
- name: route1
protocols:
- http
- https
methods:
- POST
hosts:
- abc.com
paths:
- /abc
https_redirect_status_code: 426
regex_priority: 0
strip_path: false
path_handling: v0
preserve_host: true
request_buffering: true
response_buffering: true