Skip to content

API Manager: Onboarding APIs

Deepak Narayana Rao edited this page Nov 6, 2017 · 1 revision

Context

Onboarding APIs in API manager is automated via ansible role kong-api. List of APIs to on-boarded is mentioned in kong_apis variable in ansible/roles/kong-api/defaults/main.yml

Example:

kong_apis:
  - name: createContent
    request_path: '{{ content_service_prefix }}/v1/create'
    upstream_url: '{{ content_service_url }}/v1/content/create'
    strip_request_path: true
    plugins:
    - name: jwt
    - name: cors
    - '{{ statsd_pulgin }}'
    - name: acl
      config.whitelist: contentAdmin
    - name: rate-limiting
      config.hour: '{{ medium_rate_limit_per_hour }}'
      config.limit_by: credential
    - name: request-size-limiting
      config.allowed_payload_size: '{{ small_request_size_limit }}'
  - name: searchContent
    request_path: '{{ content_service_prefix }}/v1/search'
    upstream_url: '{{ content_service_url }}/v1/content/search'
    strip_request_path: true
    plugins:
    - name: jwt
    - name: cors
    - '{{ statsd_pulgin }}'
    - name: acl
      config.whitelist: contentUser
    - name: rate-limiting
      config.hour: '{{ medium_rate_limit_per_hour }}'
      config.limit_by: credential
    - name: request-size-limiting
      config.allowed_payload_size: '{{ small_request_size_limit }}'

Onboarding new API

  • Add the new entry in APIs excel
  • Add new entry for new API in kong_apis variable in ansible/roles/kong-api/defaults/main.yml. You can copy one of the existing API entry and change values for your API

Note: If you don't have edit rights to the repo, raise a pull request with the changes

  • Run jenkins job AM_Onboard_APIs

Updating APIs

  • Change the API in excel
  • Modify the API(find by searching name of API) entry in kong_apis variable in ansible/roles/kong-api/defaults/main.yml

Note: If you don't have edit rights to the repo, raise a pull request with the changes

  • Run jenkins job AM_Onboard_APIs

Deleting APIs

  • Remove the API in excel
  • Delete the API(find by searching name of API) in kong_apis variable in ansible/roles/kong-api/defaults/main.yml

Note: If you don't have edit rights to the repo, raise a pull request with the changes

  • Run jenkins job AM_Onboard_APIs

Onboarding APIs listed in APIs excel

  • The APIs are listed in excel which has following format
NAME WHITELIST GROUP REQUEST PATH UPSTREAM PATH STATUS RATE LIMIT REQUEST SIZE LIMIT LIMIT BY
createContent contentAdmin {{ content_service_prefix }}/v1/create {{ content_service_url }}/v1/content/create Onboarded {{ medium_rate_limit_per_hour }} {{ small_request_size_limit }} credential
searchContent contentUser {{ content_service_prefix }}/v1/search {{ content_service_url }}/v1/content/search Onboarded {{ medium_rate_limit_per_hour }} {{ small_request_size_limit }} credential
  • Export the above excel to CSV format
  • Run the following command
# Ensure you have python 2.7 and python-pip installed
pip install PyYAML
python static-files/kong-api-scripts/kong_api_csv_to_yaml.py <apis_csv_file_path>

Note: If you are interested in subset of APIs, please make sure CSV has only those APIs

  • Copy the output of above command and paste it as value of kong_apis in ansible/roles/kong-api/defaults/main.yml and format the yml file appropriately
  • Run jenkins job AM_Onboard_APIs
Clone this wiki locally