Skip to content

Instantly share code, notes, and snippets.

@toopay
Last active June 18, 2018 14:07
Show Gist options
  • Save toopay/2827ac1bc8f7e1d1f2b1768e8b011129 to your computer and use it in GitHub Desktop.
Save toopay/2827ac1bc8f7e1d1f2b1768e8b011129 to your computer and use it in GitHub Desktop.
Kongfig API (via Kong Publisher)

Overview

Kong Publisher exposes a public APIs. Here are the base endpoint of Kong Publisher API, on each environment accordingly.

Environment Base Endpoint
develop https://dev-kong-publisher.command-api.kw.com/api
qa https://qa-kong-publisher.command-api.kw.com/api
production https://kong-publisher.command-api.kw.com/api

API Reference

There are 3 endpoints available :

Ednpoint HTTP Method Description
/upstreams POST Add or update your micro configuration
/upstreams GET Show your micro configuration
/builds GET Initiate a build for given x-kong-upstream-base64 name

All of these endpoints require a special header, x-kong-upstream-base64, contains a base64 encoded of your microservice registered name, and we'll walkthrough them below.

Adding or Update an Upstream - POST https://<publisher_host>/api/upstreams

You can add your microservice configuration by passing :

  • name of your microservice via x-kong-upstream-base64. Noticed that you must supply a base64 encoded value of your micro. For instance, if your microservice is Google Microservice, the passed value must be R29vZ2xlIE1pY3Jvc2VydmljZQ==.
  • config of your microservice via config key of upload file.

Below is a working example, to add Google Microservice with a valid config.yml located on /PROJECT/kwri/google-microservice/public/config.yml.

curl -v "https://dev-kong-publisher.command-api.kw.com/api/upstreams" -H"x-kong-upstream-base64: R29vZ2xlIE1pY3Jvc2VydmljZQ==" -H"Accept: application/json" -F"config=@/PROJECT/kwri/google-microservice/public/config.yml" -F"upstream_host=http://google-microservice-dev/config.yml"

Show Upstream configuration - GET https://<publisher_host>/api/upstreams

Once you had created/updated your microservice configuration, you can inspect it afterward. To do that, simply pass the name of your microservice via x-kong-upstream-base64. Noticed that you must supply a base64 encoded value of your micro. For instance, if your microservice is Google Microservice, the passed value must be R29vZ2xlIE1pY3Jvc2VydmljZQ==.

Below is a working example, to show Google Microservice configuration.

curl -v "https://dev-kong-publisher.command-api.kw.com/api/upstreams" -H"x-kong-upstream-base64: R29vZ2xlIE1pY3Jvc2VydmljZQ==" -H"Accept: application/json"

Initiate a build for your Upstream - GET https://<publisher_host>/api/builds

When everything is ready, and you want to build your microservice routes, simply pass the name of your microservice via x-kong-upstream-base64. Noticed that you must supply a base64 encoded value of your micro. For instance, if your microservice is Google Microservice, the passed value must be R29vZ2xlIE1pY3Jvc2VydmljZQ==.

Below is a working example, to initiate Google Microservice build. You should get notification on our Slack, at #eng-feed-status channel.

curl -v "https://dev-kong-publisher.command-api.kw.com/api/builds" -H"x-kong-upstream-base64: R29vZ2xlIE1pY3Jvc2VydmljZQ==" -H"Accept: application/json"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment