All Projects → mybuilder → Kongfig

mybuilder / Kongfig

Licence: mit
Declarative configuration for Kong

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Kongfig

kong-api-gateway-plugin-and-microservices-demo
Creating plugin for Kong API Gateway and Simple micro services example
Stars: ✭ 20 (-94.51%)
Mutual labels:  kong
skywalking-kong
Kong agent for Apache SkyWalking
Stars: ✭ 17 (-95.33%)
Mutual labels:  kong
kong
Kong docker image that easily installs plugins from source code.
Stars: ✭ 20 (-94.51%)
Mutual labels:  kong
dashy
Simple Stupid Kong Admin Dashboard made for my homie now available for you my homies.
Stars: ✭ 20 (-94.51%)
Mutual labels:  kong
kong-plugin-acme
Let's Encrypt and ACMEv2 integration with Kong - this plugin has been moved into https://github.com/Kong/kong, please open issues and PRs in that repo
Stars: ✭ 36 (-90.11%)
Mutual labels:  kong
django-api-bouncer
Simple Django app to provide API Gateways for micro-services
Stars: ✭ 18 (-95.05%)
Mutual labels:  kong
kong-docker
Kong Docker
Stars: ✭ 55 (-84.89%)
Mutual labels:  kong
Docker Compose Healthcheck
How to wait for container X before starting Y using docker-compose healthcheck
Stars: ✭ 292 (-19.78%)
Mutual labels:  kong
okta-api-center
Get up and running quickly with Okta's OAuth as a Service and your favorite API Gateway.
Stars: ✭ 58 (-84.07%)
Mutual labels:  kong
kong-upstream-jwt
A plugin for Kong which adds a signed JWT to HTTP Headers to backend requests
Stars: ✭ 40 (-89.01%)
Mutual labels:  kong
kong-ui
UI for KONG API Gateway
Stars: ✭ 20 (-94.51%)
Mutual labels:  kong
kong-map
Kongmap is a free visualization tool which allows you to view and edit configurations of your Kong API Gateway Clusters, including Routes, Services, and Plugins/Policies. The tool is being offered for installation via Docker and Kubernetes at this time.
Stars: ✭ 60 (-83.52%)
Mutual labels:  kong
kong-plugin-http-anti-replay-attack
http-anti-replay-attack [防重放攻击]
Stars: ✭ 20 (-94.51%)
Mutual labels:  kong
dockerize-and-ansible
🐳 Build & Deploy the containerized Dev & Prod Env
Stars: ✭ 20 (-94.51%)
Mutual labels:  kong
docker-service-registrator-kong
A docker service registrator for the Kong API Gateway
Stars: ✭ 14 (-96.15%)
Mutual labels:  kong
Kong-API-Manager
Kong API Manager with Prometheus And Graylog
Stars: ✭ 78 (-78.57%)
Mutual labels:  kong
kong-circuit-breaker
Kong plugin for wrapping all proxy calls with a circuit-breaker
Stars: ✭ 27 (-92.58%)
Mutual labels:  kong
Konga
More than just another GUI to Kong Admin API
Stars: ✭ 3,596 (+887.91%)
Mutual labels:  kong
kong-scalable-rate-limiter
Kong plugin for Rate Limiting at high throughputs.
Stars: ✭ 19 (-94.78%)
Mutual labels:  kong
kong-config-manager
Yet another Kong CLI tool who can dump live configurations and apply your own backup configurations. In other words, configuration as code (CAC).
Stars: ✭ 15 (-95.88%)
Mutual labels:  kong

Kongfig

A tool for Kong to allow declarative configuration.

Simply define your list of APIs and consumers in json and then run kongfig to ensure that your Kong is configured correctly.

Build Status

Install

Manually

We recommend installing Kongfig globally

npm install -g kongfig

Puppet

Use our Puppet-Kongfig module to install and configure Kongfig

puppet module install mybuilder-kongfig

Quick start

You can follow the quick start to get going in 5 minutes.

Apply config

You can have your config in json, yaml, or js if you need to support multiple environments.

kongfig apply --path config.yml --host localhost:8001

Dump config

You can dump the existing configuration to a file or view it on a screen

kongfig dump --host localhost:8001 > config.yml

You can omit the --host option if kong is on localhost:8001 as this is the default value

You can specify the desired format by giving --format option with possible options of json, yaml, or screen that prints the config with colours.

kongfig dump --format screen

For APIs which uses custom consumer credential plugins, specify plugin and id name in : format with --credential-schema option.

kongfig apply --path config.yml --host localhost:8001 --credential-schema custom_jwt:key

For multiple plugins use --credential-schema as many as necessary

kongfig apply --path config.yml --host localhost:8001 --credential-schema "custom_jwt:key" --credential-schema "custom_oauth2:client_id"

Schema

Note: If you change the name of an API/Plugin/Consumer and want to ensure the old one is removed automatically, do not delete or modify the old API/Plugin/Consumer section, other than to add the ensure: "removed" flag. Examples shown below.

Notice the attributes.username config parameter below, this is used to map given username to consumer uuid

Api schema:

apis:
  - name: mockbin # unique api name
    ensure: "present" # Set to "removed" to have Kongfig ensure the API is removed. Default is present.
    attributes:
      upstream_url: string # (required)
      hosts: [string]
      uris: [string]
      methods: ["POST", "GET"]
      strip_uri: bool
      preserve_host: bool
      retries: int
      upstream_connect_timeout: int
      upstream_read_timeout: int
      upstream_send_timeout: int
      https_only: bool # (required)
      http_if_terminated: bool

Api plugin schema:

apis:
  - name: mockbin # unique api name
    attributes: # ...
    plugins:
      - name: rate-limiting # kong plugin name
        ensure: "present" # Set to "removed" to have Kongfig ensure the plugin is removed. Default is present.
        attributes: # the plugin attributes
          username: # optional, to reference a consumer, same as consumer_id in kong documentation
          config:

Global plugin schema:

plugins:
  - name: cors
    attributes:
      username: # optional, to reference a consumer, same as consumer_id in kong documentation
      enabled: true
      config:
        credentials: false
        preflight_continue: false
        max_age: 7000

All of the kong plugins should be supported if you find one that doesn't work please add an issue.

Consumer schema:

consumers:
  - username: iphone-app
    custom_id: foobar-1234 # optional

Consumer credential schema:

consumers:
  - username: iphone-app
    credentials:
      - name: key-auth
        attributes: # credential config attributes

Consumer ACL schema:

consumers:
  - username: iphone-app
    acls:
      - group: acl-group-name

Supported consumer credentials

Notice the anonymous_username config parameter below, this is used to map username to consumer uuid

Key Authentication

apis:
  - name: mockbin # unique api name
    attributes: # ...
    plugins:
      - name: key-auth
        attributes:
          config:
            anonymous_username: # optional, same as just anonymous in kong api, maps given username to consumer uuid
            key_names:
            hide_credentials:

consumers:
  - username: iphone-app
    credentials:
      - name: key-auth
        attributes:
          key: # required

Basic Authentication

apis:
  - name: mockbin
    attributes: # ...
    plugins:
      - name: basic-auth
        attributes:
          config:
            hide_credentials:

consumers:
  - username: iphone-app
    credentials:
      - name: basic-auth
        attributes:
          username: # required
          password:

OAuth 2.0 Authentication

apis:
  - name: mockbin
    attributes: # ...
    plugins:
      - name: oauth2
        attributes:
          config:
            scopes:
            mandatory_scope:
            token_expiration:
            enable_authorization_code:
            enable_client_credentials:
            enable_implicit_grant:
            enable_password_grant:
            hide_credentials:

consumers:
  - username: iphone-app
    credentials:
      - name: oauth2
        attributes:
          name:
          client_id: # required
          client_secret:
          redirect_uri: string | [string] # required by kong

HMAC Authentication

apis:
  - name: mockbin
    attributes: # ...
    plugins:
      - name: hmac-auth
        attributes:
          config:
            hide_credentials:
            clock_skew:

consumers:
  - username: iphone-app
    credentials:
      - name: hmac-auth
        attributes:
          username: # required
          secret:

JWT

apis:
  - name: mockbin
    attributes: # ...
    plugins:
      - name: jwt
        attributes:
          config:
            uri_param_names:
            claims_to_verify:

consumers:
  - username: iphone-app
    credentials:
      - name: jwt
        attributes:
          key: # required
          secret:

Custom Credential Schemas

It is possible to work with custom consumer credential plugins.

apis:
  - name: mockbin
    attributes: # ...
    plugins:
      - name: custom_jwt
        attributes:
          config:
            uri_param_names:
            claims_to_verify:

consumers:
  - username: iphone-app
    credentials:
      - name: custom_jwt
        attributes:
          key: # required
          secret:

credentialSchema:
  custom_jwt:
    id: "key" # credential id name

ACL Support

Kong ACL documentation

apis:
  - name: mockbin
    attributes: # ...
    plugins:
      - name: "acl"
        ensure: "present"
        attributes:
          config.whitelist: "foo-group"

consumers:
  - username: "some-username"
    ensure: "present"
    acls:
      - group: "foo-group"
        ensure: "present"

      - group: "bar-group"
        ensure: "present"

Upstream/Target Schema

Kong Upstream Load Balancing Reference

upstreams:
  - name: "mockbinUpstream"
    ensure: "present"
    targets:
      - target: "server1.mockbin:3001"
        attributes:
          weight: 50
      - target: "server2.mockbin:3001"
        attributes:
          weight: 50
    attributes:
      slots: 100

Certificates & SNIs

A certificate object represents a public certificate/private key pair for an SSL certificate. These objects are used by Kong to handle SSL/TLS termination for encrypted requests. Certificates are optionally associated with SNI objects to tie a cert/key pair to one or more hostnames.

Kong Certificate Object Reference

An SNI object represents a many-to-one mapping of hostnames to a certificate. That is, a certificate object can have many hostnames associated with it; when Kong receives an SSL request, it uses the SNI field in the Client Hello to lookup the certificate object based on the SNI associated with the certificate.

Kong SNI Objects Reference

certificates:
  - ensure: present
    cert: >-
      -----BEGIN CERTIFICATE-----
      MIIDMjCCAhqgAwIBAgIJAPgRdnOdnX/SMA0GCSqGSIb3DQEBBQUAMBoxGDAWBgNV
      ....
    key: >-
      -----BEGIN RSA PRIVATE KEY-----
      MIIEpAIBAAKCAQEAo5BpOQY2AV/1L2QEdSip75rHh3Khs2knNtMLIrP26MHyidtX
      ....
    snis:
      - name: example.com
        ensure: present
      - name: www.example.com
        ensure: present

Notice that SNIs are an list of object e.g. { name: example.com, ensure: present } different Kong api itself where it is a list of hostnames

Migrating from Kong <=0.9 to >=0.10

kongfig translates pre >=0.10 kong config files automatically when applying them.

So you can export your config from <=0.9 kong instance by running:

kongfig dump --host kong_9:8001 > config.v9.yml

Then apply it to kong 0.10 instance

kongfig apply --path config.v9.yml --host kong_10:8001

apis endpoint changed between <=0.9 and >=0.10:

  • request_host: string to hosts: [string]
  • request_path: string to uris: [string]
  • strip_request_path: bool -> strip_uri: bool
  • Adds methods, retries, upstream_connect_timeout, upstream_read_timeout, upstream_send_timeout, https_only, http_if_terminated

Created by MyBuilder - Check out our blog for more information and our other open-source projects.

Contributing to Kongfig

We are very grateful for any contributions you can make to the project.

Visit the Contributing documentation for submission guidelines.

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].