> For the complete documentation index, see [llms.txt](https://kdongs.gitbook.io/kdocs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kdongs.gitbook.io/kdocs/kong-api-gateway/kong-api-gateway.md).

# Kong API Gateway

{% embed url="<https://docs.konghq.com/gateway/latest/>" %}

## About

An open source API Gateway, with characteristics of a [API Gateway](/kdocs/api-gateway/api-gateway.md#micro-gateways).

It has flexible deployment *(meaning it can be used not only at the architecture's edge, but also managing Services integrations)*, Kubernetes ready and it is also extensible with Plugins.

<img src="https://2809847567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxO11MVi4IotfBndtyLDQ%2Fuploads%2FcnHPMoJkk4aRLPVWomFO%2Ffile.excalidraw.svg?alt=media&amp;token=873791b6-df1b-47d3-9fa7-1f96898a1c43" alt="" class="gitbook-drawing">

## Deployment Models

### Distributed

All Kong instances have access to the database.

{% hint style="info" %}
This distributed deployment mode is only available at paid enterprise version.
{% endhint %}

<img src="https://2809847567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxO11MVi4IotfBndtyLDQ%2Fuploads%2FXGpLhfuHlrcIzvZhQPSx%2Ffile.excalidraw.svg?alt=media&amp;token=14a0740f-7a5b-4386-8fff-d0b9c2d825ce" alt="" class="gitbook-drawing">

### Hybrid

The recommended model, where only the Control Plane access the Database, reducing usage of the database.

<img src="https://2809847567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxO11MVi4IotfBndtyLDQ%2Fuploads%2FCnhFl167JUmaN1qLRbVM%2Ffile.excalidraw.svg?alt=media&amp;token=d3c72607-7edb-498b-a80f-d55d2f3d20f1" alt="" class="gitbook-drawing">

### DB-Less

The source of truth is the declarative `.yaml` or `.json` file that includes all the configuration and that is parsed in-memory when Kong starts.

{% hint style="danger" %}
Some Kong Plugins are not compatible with `Db-Less`.
{% endhint %}

<img src="https://2809847567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxO11MVi4IotfBndtyLDQ%2Fuploads%2FrUmF6GqsaQOhT60n8oJZ%2Ffile.excalidraw.svg?alt=media&amp;token=a354a9c0-efc3-4406-a54b-021a52991c02" alt="" class="gitbook-drawing">

### With Database

The source of truth is the shared datase (postgreSQL or Cassandra) that is a required dependency for every Kong node in the same cluster.

<img src="https://2809847567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxO11MVi4IotfBndtyLDQ%2Fuploads%2FJvPqI47Y46NFSMnaTXW7%2Ffile.excalidraw.svg?alt=media&amp;token=e787f159-f593-4c24-9109-1eac380a2bde" alt="" class="gitbook-drawing">

## Getting Started

### [Kong Services](https://docs.konghq.com/gateway/3.9.x/key-concepts/services/)

A service is an entity that represents an (API or Microservice) `upstream`. *(Ex.: An Invoice Microservice)*

{% hint style="info" %}
An `upstream` is always your available API or Microservice.
{% endhint %}

When configuring a service you can specify:

* Service name;
* Description of service;
* Tags;
* Url that will be used to reach the API or Microservice inside the network *(Ex.:* `http://api-container:3000`*)*;
* Retries, amount of retries for a request to try reaching the service;
* Connection timeout;
* etc.

#### [Rate Limiting](https://docs.konghq.com/gateway/3.9.x/get-started/rate-limiting/)

Rate Limiting can be done on the Service level, by configuring the plugin for each Service.

{% hint style="danger" %}
Always hide headers for `too many requests`.
{% endhint %}

Check more on the docs.

### [Kong Routes](https://docs.konghq.com/gateway/3.9.x/key-concepts/routes/)

A Route is how *(the URL)* Kong will reach the Service.

You create Routes from inside the Service panel in `Konga`.

{% hint style="warning" %}
Just setting up the `url` in the service is not enough.

You have to explicitly create a Route to the upstream.
{% endhint %}

When configuring a route the main configurations are:

* Route name;
* Route tags;
* Route `host` *(a list of hosts)*, a `header` variable that must be sent on the request *(Ex.:* `{ Host: api-url.com }`*) (**If configured,** it MUST be sent on the request headers);*
* Route `paths` (a list of paths), very important, which is part of the URL that comes from the `downstream` *(Ex.: /api/v1);*
* etc.

With `host` and `paths` you can route different URLs to different services.

### [Kong Consumers](https://docs.konghq.com/gateway/3.9.x/key-concepts/consumers/)

A consumer typically refers to an entity that consumes or uses the APIs managed by Kong Gateway. *(Like applications, services, or users)*

Kong allows you to manage them, apply access control policies, and monitor their API usage.

They are identified by key authorization, OAuth, or other authentication and authorization mechanisms.

<img src="https://2809847567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxO11MVi4IotfBndtyLDQ%2Fuploads%2FufdsFxul3p6dK6Ck4Dbw%2Ffile.excalidraw.svg?alt=media&amp;token=69e5ba42-b39a-406f-9a09-3e269d940e93" alt="" class="gitbook-drawing">

### [Kong Plugins](https://docs.konghq.com/gateway/3.9.x/key-concepts/plugins/)

They provide additional functionality and extend the use of Kong.

You may create plugins in `go`, `python`, `javascript` and `lua`.

Check third-party plugins available [here](https://docs.konghq.com/hub/).

## [Konga](https://pantsel.github.io/konga/)

Konga is an Admin Interface for Kong API Gateway, useful to see Kong instance's metrics and do user management.

It can also manage multiple Kongs.
