You are browsing documentation for an outdated version.
See the latest documentation here.
Expose your Services with Kong Gateway
In this topic, you’ll learn how to expose your Services using Routes.
If you are following the Getting Started workflow, make sure you have completed
Prepare to Administer Kong Gateway
before moving on.
If you are not following the Getting Started workflow, make sure you have
Kong Gateway installed and started.
What are Services and Routes?
Service and Route objects let you expose your services to clients with
Kong Gateway. When configuring access to your API, you’ll start by specifying a
Service. In Kong Gateway, a Service is an entity representing an external
upstream API or microservice — for example, a data transformation
microservice, a billing API, and so on.
The main attribute of a Service is its URL, where the service listens for
requests. You can specify the URL with a single string, or by specifying its
protocol, host, port, and path individually.
Before you can start making requests against the Service, you will need to add
a Route to it. Routes determine how (and if) requests are sent to their Services
after they reach Kong Gateway. A single Service can have many Routes.
After configuring the Service and the Route, you’ll be able to start making
requests through Kong Gateway.
This diagram illustrates the flow of requests and responses being routed through
the Service to the backend API.
Add a Service
For the purpose of this example, you’ll create a Service pointing to the httpbin
API. Httpbin is an “echo” type public website that returns requests back to the
requester as responses. This visualization will be helpful for learning how Kong
Gateway proxies API requests.
Kong Gateway exposes the RESTful Admin API on port
8001. The gateway’s
configuration, including adding Services and Routes, is done through requests to
the Admin API.
Add a Route
For the Service to be accessible through the API gateway, you need to add a
Route to it.
Verify the Route is forwarding requests to the Service
By default, Kong Gateway handles proxy requests on port
8000. The proxy is often referred to as the data plane.
Summary and next steps
In this section, you:
- Added a Service named
example_service with a URL of
- Added a Route named
- This means if an HTTP request is sent to the Kong Gateway node on
8000(the proxy port) and it matches route
/mock, then that request is
- Abstracted a backend/upstream service and put a route of your choice on the
front end, which you can now give to clients to make requests.
Next, go on to learn about enforcing rate limiting.