项目作者: LuanP

项目描述 :
Kong API Gateway Config Manager
高级语言: JavaScript
项目地址: git://github.com/LuanP/konfig-manager.git
创建时间: 2019-03-11T13:10:06Z
项目社区:https://github.com/LuanP/konfig-manager

开源协议:

下载


konfig-manager

Kong API Gateway Config Manager

Travis
Coverage Status
oclif
Version
Downloads/week
License
Known Vulnerabilities
Sonar Tech Debt

  • Usage
  • Commands

    Usage

    1. $ npm install -g konfig-manager
    2. $ konfig COMMAND
    3. running command...
    4. $ konfig (-v|--version|version)
    5. konfig-manager/1.5.0 darwin-x64 node-v12.13.0
    6. $ konfig --help [COMMAND]
    7. USAGE
    8. $ konfig COMMAND
    9. ...

Docker

Here’s an example of how to use this library with docker multi stage:

  1. FROM node:lts-alpine as konfig-manager
  2. RUN npm install -g konfig-manager@1.4.4 --production
  3. FROM kong:1.2.1-alpine as api-gateway
  4. COPY --from=konfig-manager /usr/local/ /usr/local/
  5. ...

Custom configuration

This library allows you to replace content based on the resource type (plugins, routes, …) when dumping and to perform substitutions based on environment variabled when running loading.

Here it follows a .konfigrc example:

  1. {
  2. "load": {
  3. "substitutions": {
  4. "environment_variables": {
  5. "enabled": true,
  6. "white_list": ["SERVER_PROTOCOL", "SERVER_HOST", "SERVER_PORT"],
  7. "types": {
  8. "TRUSTED_ORIGINS": "list"
  9. }
  10. }
  11. }
  12. },
  13. "sync": {
  14. "substitutions": {
  15. "environment_variables": {
  16. "enabled": true,
  17. "white_list": ["SERVER_PROTOCOL", "SERVER_HOST", "SERVER_PORT", "TRUSTED_ORIGINS"],
  18. "types": {
  19. "TRUSTED_ORIGINS": "list"
  20. }
  21. }
  22. }
  23. },
  24. "dump": {
  25. "substitutions": {
  26. "plugins": {
  27. "config": {
  28. "introspection_endpoint": "${SERVER_PROTOCOL}://${SERVER_HOST}:${SERVER_PORT}/openid/introspect",
  29. "discovery": "${SERVER_PROTOCOL}://${SERVER_HOST}:${SERVER_PORT}/openid/.well-known/openid-configuration",
  30. "trusted_origins": "${TRUSTED_ORIGINS}"
  31. }
  32. },
  33. "routes": {
  34. "hosts": [
  35. "${SERVER_HOST}"
  36. ]
  37. }
  38. },
  39. "exceptions": {
  40. "routes": [
  41. {
  42. "key": "name",
  43. "value": "do-not-change-this-route"
  44. }
  45. ]
  46. }
  47. }
  48. }

Load / sync with several files

You can run the command by passing the --file several times to merge it.

  1. konfig sync --file minimal-konfig.json --file konfig.json

NOTE: If duplicated id’s are found in a collection, the data from the last file passed will be kept.

Commands

konfig dump

Dump available Kong data in a file

  1. USAGE
  2. $ konfig dump
  3. OPTIONS
  4. --file=file [default: konfig.json] name of file to be created as output
  5. --url=url [default: http://localhost:8001] URL of the Kong Admin API
  6. DESCRIPTION
  7. It requests data from Kong API endpoints and save the results in a file.

See code: src/commands/dump.js

konfig flush

Flush available Kong data

  1. USAGE
  2. $ konfig flush
  3. OPTIONS
  4. --url=url [default: http://localhost:8001] URL of the Kong Admin API
  5. DESCRIPTION
  6. It requests the endpoints getting the available data and calls the DELETE endpoints.

See code: src/commands/flush.js

konfig help [COMMAND]

display help for konfig

  1. USAGE
  2. $ konfig help [COMMAND]
  3. ARGUMENTS
  4. COMMAND command to show help for
  5. OPTIONS
  6. --all see all commands in CLI

See code: @oclif/plugin-help

konfig load

Load available Kong data from a file

  1. USAGE
  2. $ konfig load
  3. OPTIONS
  4. --file=file [default: konfig.json] name of file to be loaded
  5. --url=url [default: http://localhost:8001] URL of the Kong Admin API
  6. DESCRIPTION
  7. It gets data from a file and loads in Kong Admin API endpoints.

See code: src/commands/load.js

konfig sync

Sync data from file with a Kong Admin API

  1. USAGE
  2. $ konfig sync
  3. OPTIONS
  4. --file=file [default: konfig.json] name of file to be loaded
  5. --url=url [default: http://localhost:8001] URL of the Kong Admin API
  6. DESCRIPTION
  7. It gets data from a Kong Admin API and sync based on the files provided.

See code: src/commands/sync.js