Implement and Test a Service
Create a service implementation to expose your Konnect service to clients.
When you create an implementation, you also specify the route to it. This route, combined with the proxy URL for the service, will lead to the endpoint specified in the service implementation.
Prerequisites
If you’re following the Konnect quickstart guide, make sure you have configured a service.
Implement a service version
-
In the
Service Hub, open a service, then pick a version.
For example, use
example_service
with a version namedv1
. -
Click New Implementation.
-
In the Create Implementation dialog, in step 1, create a new service implementation to associate with your service version.
- Enter a unique name for the Gateway service, or specify a Gateway service that doesn’t yet have a version connected to it.
For the purpose of this example, enter
example_gateway_service
.The name can be any string containing letters, numbers, or the following characters:
.
,-
,_
,~
, or:
. Do not use spaces.For example, you can use
example_service
,ExampleService
,Example-Service
. However,Example Service
is invalid.-
In the URL field, enter
http://mockbin.org
. -
Use the defaults for the remaining fields.
-
Click Next.
-
Add a route to your service implementation.
For this example, enter the following:
-
Name:
mockbin
-
Method:
GET
-
Path(s): Click Add Path and enter
/mock
For the remaining fields, use the default values listed.
-
Name:
-
Click Create.
The
v1
service version overview displays.If you want to view the configuration, edit or delete the implementation, or delete the version, click the Version actions menu.
Check the Gateway service
Every time you create a service implementation, Konnect creates or connects to a parallel Kong Gateway service to proxy requests based on your configuration. Let’s check out the service you just created.
-
From the main menu, open the
Runtime Manager.
-
Open the runtime group that you chose for your service version.
-
Open Gateway Services from the sub-menu, then click on the
example_gateway_service
. -
Take a look at the tags to see the connected Konnect service:
_KonnectService:example_service
You can manage your Gateway service from here, or from the Service Hub, through the service implementation. All changes will be reflected in both locations.
Verify the implementation
If you used the Docker script to create a container
earlier in Configure a Runtime,
your runtime’s default proxy URL is localhost:8000
.
Enter the proxy URL into your browser’s address bar and append the route path you just set. The final URL should look something like this:
http://localhost:8000/mock
If successful, you should see the homepage for mockbin.org
. On your service
version overview page, you’ll see a record for status code 200. This might
take a few moments.
And that’s it! You have your first service set up, running, and routing traffic proxied through a Kong Gateway runtime.
Summary and next steps
To summarize, in this topic you:
- Implemented the service version
v1
with the route/mock
. This means if an HTTP request is sent to the Kong Gateway node and it matches route/mock
, that request is sent tohttp://mockbin.org
. - 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, publish the service to the Dev Portal and test out the Portal from the perspective of a developer.