All Projects → liyuntao → kong-init

liyuntao / kong-init

Licence: Apache-2.0 license
Declarative configuration tool for Kong

Programming Languages

rust
11053 projects
Dockerfile
14818 projects
shell
77523 projects

Projects that are alternatives of or similar to kong-init

docker-kong-oidc
Kong + OIDC plugins
Stars: ✭ 83 (+118.42%)
Mutual labels:  gateway, kong
gluu-gateway
Gluu API 🚀 and Web Gateway 🎯
Stars: ✭ 29 (-23.68%)
Mutual labels:  gateway, kong
skywalking-kong
Kong agent for Apache SkyWalking
Stars: ✭ 17 (-55.26%)
Mutual labels:  gateway, kong
S3auth
Amazon S3 HTTP Basic Auth Gateway
Stars: ✭ 249 (+555.26%)
Mutual labels:  gateway
Davmail
DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange and Office 365 Gateway - Synced with main subversion repository at
Stars: ✭ 250 (+557.89%)
Mutual labels:  gateway
payum-ecpay
The Payum extension. 綠界金流
Stars: ✭ 13 (-65.79%)
Mutual labels:  gateway
api-gateway
Node.js API gateway that works as single entry point for all clients in a MicroService architecture pattern.
Stars: ✭ 26 (-31.58%)
Mutual labels:  gateway
Qtgate Desktop Client
A revolutionary internet infrastructure enabling a truly free Network, that offers Stability, Trust, Privacy, and Security
Stars: ✭ 232 (+510.53%)
Mutual labels:  gateway
node-lumi-aqara
Control your Xiaomi Smart Home devices with this Lumi Aqara library
Stars: ✭ 45 (+18.42%)
Mutual labels:  gateway
WHMCS-JSJ-API-Pay-Gateway
WHMCS 财务系统对接金莎云免签支付API(你们怎么用,与我无瓜好吧:)
Stars: ✭ 58 (+52.63%)
Mutual labels:  gateway
kongsul
Kong Api Gateway with Consul Service Discovery (MicroService)
Stars: ✭ 35 (-7.89%)
Mutual labels:  kong
Springcloudlearning
《史上最简单的Spring Cloud教程源码》
Stars: ✭ 16,218 (+42578.95%)
Mutual labels:  gateway
SmartGW
Domain based VPN Gateway/Proxy for all devices
Stars: ✭ 49 (+28.95%)
Mutual labels:  gateway
Springcloud
springCloud学习
Stars: ✭ 251 (+560.53%)
Mutual labels:  gateway
consul-api-gateway
The Consul API Gateway is a dedicated ingress solution for intelligently routing traffic to applications running on a Consul Service Mesh.
Stars: ✭ 88 (+131.58%)
Mutual labels:  gateway
Mbusd
Open-source Modbus TCP to Modbus RTU (RS-232/485) gateway.
Stars: ✭ 233 (+513.16%)
Mutual labels:  gateway
QUaModbusClient
Modbus to OPC UA Gateway
Stars: ✭ 38 (+0%)
Mutual labels:  gateway
MPContribs
Platform for materials scientists to contribute and disseminate their materials data through Materials Project
Stars: ✭ 30 (-21.05%)
Mutual labels:  kong
kong-plugin-url-rewrite
Kong API Gateway plugin for url-rewrite purposes
Stars: ✭ 43 (+13.16%)
Mutual labels:  kong
citrix-adc-aws-cloudformation
Citrix ADC (Formerly Netscaler) templates and scripts for AWS deployment
Stars: ✭ 11 (-71.05%)
Mutual labels:  gateway

Build Status License

Introduction

kong-init is a tool for Kong to allow automatic declarative configuration, written in rust.

key feature

  • declarative configuration(using yaml)
  • support kong CE 0.11.X ~ 0.14.X (currently not tested under version <= 0.10.X)
  • support kong EE 0.30 ~ 0.33
  • support api-definition & service/route definition
  • support consumer initialization
  • support credentials initialization (jwt/oauth/acls)
  • support cloud environment (docker)

requirement

  • run on linux: openssl v1.1 (due to dependency link reqwest -> rust-native-tls -> openssl 1.1)
  • run on mac/windows: no extra dependency
  • development: rust 1.30.1

Getting started

more detailed explanation can be found under example folder.

API style definition

Declare API style configurations in a yaml file.

apis:
  - name: cookie-api
    uris: /api/v1/cookie
    methods: GET,POST,HEAD,PUT
    upstream_url: http://service01:8080/api/v1/cookie

plugins:
  - name: jwt
    plugin_type: jwt
    target_api: cookie-api
    config:
      uri_param_names: jwt
      secret_is_base64: false

Service/Route style definition

Declare Service/Route style configurations in a yaml file. Suit for kong version >= 0.13

services:
  - name: netdisk
    url: http://host.docker.internal:8090
  - name: dummy
    url: http://host.docker.internal:7090/dummy

routes:
  - name: r-netdisk
    apply_to: netdisk
    config:
      paths: ["/api/v1/netdisk"]
      strip_path: false
  - name: r-dummy
    apply_to: dummy
    config:
      paths: ["/dummy"]
      strip_path: true
  - name: r-dummy-no-auth
    apply_to: dummy
    config:
      paths: ["/dummy/login"]
      strip_path: true

run the command

# download the latest binary file located in https://github.com/liyuntao/kong-init/releases
# or build from source if you have rust installed: cargo build

kong-init --path ./example/kong11.yaml --url http://localhost:8001

Command-line options

USAGE:
    kong-init [FLAGS] [OPTIONS] --url <admin-url> --path <path>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information
    -w, --wait       wait until kong-server is ready(suit for init under cloud environment)

OPTIONS:
        --url <admin-url>       admin url of kong-server(e.g. http://kong_ip:8001)
        --header <header>...    add custom header for admin-api request
    -p, --path <path>           path to route defination file

advanced usage

debug mode

kong-init use env_logger for logging, which is a simple logger can be configured via environment variables.

# set log_level to debug
RUST_LOG=kong_init=debug kong-init --path ./example/kong11.yaml --url http://localhost:8001

env var replacing:

one can define any environment var using ${env_name} in yaml file. The env var will be replaced by it's value at runtime.

apis:
  - name: cookie-api
    uris: /api/v1/cookie
    methods: GET,POST,HEAD,PUT
    upstream_url: http://service01:${my_port}/api/v1/cookie
# env var replacing example
my_port=8081 kong-init --path ./example/kong11.yaml --url http://localhost:8001

useful built-in instructions:

1)k-upsert-consumer
  • scenario: In some scenarios, we want our api can support both request with or without jwt header(do not return 401 if without jwt). So we must configure config.anonymous. However this field can only accepts an uuid with existing consumer, not so convenient for our initialization. We can use k-upsert-consumer directive to acheve this. It will replaced by a real uuid at runtime.
  • ability: using given consumer_id to fetch or create the uuid of consumer. (will fetch if consumer exists for idempotent initialization)
  • args: consumer_id
  • usage: {{k-upsert-consumer:<custom_name_str>}}
apis:
  - name: cookie-api
    uris: /api/v1/cookie
    methods: GET,POST,HEAD,PUT
    upstream_url: http://service01:8080/api/v1/cookie
  - name: jar-api
    uris: /api/v1/jar
    upstream_url: http://service02:8080/api/v1/jar

plugins:
  - name: strict-jwt # will return 401 if request without token
    plugin_type: jwt
    target_api: cookie-api
    config:
      uri_param_names: jwt
      secret_is_base64: false
  - name: nonstrict-jwt # will fallback to specified user/consumer if request without token
    plugin_type: jwt
    target_api: jar-api
    config:
      uri_param_names: jwt
      secret_is_base64: false
      anonymous: {{k-upsert-consumer:guest_user}}

Thanks to

People came together to create and keep improving kong-init. Couldn’t have done it without all of you.

  • @cilindrox
  • @kuryaki
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].