Map Gateway Manager Services in Service Catalog

TL;DR

Create a Service Catalog service and associate it with your Gateway Manager resources to visualize Services across multiple Control Planes.

Prerequisites

This is a Konnect tutorial and requires a Konnect personal access token.

  1. Create a new personal access token by opening the Konnect PAT page and selecting Generate Token.

  2. Export your token to an environment variable:

     export KONNECT_TOKEN='YOUR_KONNECT_PAT'
    
  3. Run the quickstart script to automatically provision a Control Plane and Data Plane, and configure your environment:

     curl -Ls https://get.konghq.com/quickstart | bash -s -- -k $KONNECT_TOKEN --deck-output
    

    This sets up a Konnect Control Plane named quickstart, provisions a local Data Plane, and prints out the following environment variable exports:

     export DECK_KONNECT_TOKEN=$KONNECT_TOKEN
     export DECK_KONNECT_CONTROL_PLANE_NAME=quickstart
     export KONNECT_CONTROL_PLANE_URL=https://us.api.konghq.com
     export KONNECT_PROXY_URL='http://localhost:8000'
    

    Copy and paste these into your terminal to configure your session.

decK is a CLI tool for managing Kong Gateway declaratively with state files. To complete this tutorial, install decK version 1.43 or later.

This guide uses deck gateway apply, which directly applies entity configuration to your Gateway instance. We recommend upgrading your decK installation to take advantage of this tool.

You can check your current decK version with deck version.

For this tutorial, you’ll need Kong Gateway entities, like Gateway Services and Routes, pre-configured. These entities are essential for Kong Gateway to function but installing them isn’t the focus of this guide. Follow these steps to pre-configure them:

  1. Run the following command:

    echo '
    _format_version: "3.0"
    services:
      - name: example-service
        url: http://httpbin.konghq.com/anything
    ' | deck gateway apply -
    

To learn more about entities, you can read our entities documentation.

Create a service in Service Catalog

In this tutorial, you’ll map Gateway Services from Gateway Manager to a service in Service Catalog. Because the Gateway Manager integration is built-in, you don’t need to install or authorize it like other Service Catalog integrations.

Create a service that you’ll map to your Gateway Manager resources:

 curl -X POST "https://us.api.konghq.com/v1/catalog-services" \
     -H "Authorization: Bearer $KONNECT_TOKEN" \
     --json '{
       "name": "billing",
       "display_name": "Billing Service"
     }'

Export the Service Catalog service ID:

export SERVICE_ID='YOUR-SERVICE-ID'

List Gateway Manager resources

Before you can map a resource to Service Catalog, you first need to find the resources that are pulled in from Gateway Manager:

 curl -X GET "https://us.api.konghq.com/v1/resources?filter%5Bintegration.name%5D=gateway-manager" \
     -H "Authorization: Bearer $KONNECT_TOKEN"

Export the resource ID you want to map to the service:

export GATEWAY_MANAGER_RESOURCE_ID='YOUR-RESOURCE-ID'

Map resources to a Service Catalog service

Now, you can map the Gateway Manager resource to the service:

 curl -X POST "https://us.api.konghq.com/v1/resource-mappings" \
     -H "Authorization: Bearer $KONNECT_TOKEN" \
     --json '{
       "service": "'$SERVICE_ID'",
       "resource": "'$GATEWAY_MANAGER_RESOURCE_ID'"
     }'

Validate the mapping

To confirm that the Gateway Manager resource is now mapped to the intended service, list the service’s mapped resources:

 curl -X GET "https://global.api.konghq.com/v1/catalog-services/$SERVICE_ID/resources" \
     -H "Authorization: Bearer $KONNECT_TOKEN"
Something wrong?

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!