Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Continuous Integration and Deployment for API Management

DZone's Guide to

Continuous Integration and Deployment for API Management

In this post, an integration developer explains how API engineers can use DevOps processes, such as CI/CD, to better create and manage their APIs.

· Integration Zone ·
Free Resource

SnapLogic is the leading self-service enterprise-grade integration platform. Download the 2018 GartnerMagic Quadrant for Enterprise iPaaS or play around on the platform, risk free, for 30 days.

Introduction

APIs are the defacto standard for connecting data, services, and apps to build business solutions to cater ever-changing consumer preferences. To seize the opportunities the organizations need to act fast and keep connecting and delivering solutions to the consumers not in weeks or months, but in hours or days. Even though you have well-designed core APIs, to deliver new business capabilities, you have to keep changing APIs and manage the complete life-cycle of it. It is a must that you build continuous integration and delivery into your API programs in delivering the digital transformation your organization and consumers expect.

Continuous integration is the developer practice of merging the source code into a shared repository frequently and verification process to detect errors quickly and fix. The changes are validated using an automated build and test suites upon receiving commits to the master branch.

Continuous delivery is the process of deploying and delivering the new changes to the customers in a sustainable way. This is often achieved by automated deployments of the changes into multiple runtimes such as staging and pre-prod. If your release pipeline is automated up to production environment too without human interactions, that is the continuous deployment. Having a continuous deployment pipeline increases the confidence of customers, accelerates the feedback loop and finally, it is the success of customers.

API Management and CI/CD

API Management

  • Implementing CI/CD processes for API Management solutions span from development of the backend services to API lifecycle management. This is because the API definition is tightly coupled with your backend service implementation. In certain situations, you orchestrate your backend services together and expose a single interface to the consumers. But it is advised to follow API Façade pattern when you have to expose disconnected services to your consumers.
  • The development of the backend service is either RESTful or based on SOAP, you use design first or code first approaches by considering the development team capabilities, time to go live, etc.
  • The source code on the version control system can be structured considering the different aspects of the CI/CD pipeline. As an example:
    BackendServiceImplimentation
       src
    BackendServiceDeployment
       scripts
           deploy.sh
    APIDeployment
       scripts
           postman collections
       resources
           definition
               swagger
               WSDL
           mediation policies
               JSON to XML transform
               SOAP to REST transform
           documents
               getting started guide
    APITesting
       scripts
           postman collections
    DevEnvironment
    	backendService.properties
    	development.postman_environment.json
    StagingEnvironment
    	backendService.properties
    	staging.postman_environment.json
    ProductionEnvironment
    	backendService.properties
    	production.postman_environment.json
  • The sensitive data is configured on the CI server using its own encryption mechanisms such as encrypted values in Travis.
  • Deployment of backend services and APIs can leverage the management APIs provided by the API management solution. Ability to deploy APIs, update API documents (Swagger, WSDL, how to guides), create new versions, promote, demote, retire APIs, etc., using REST APIs is a key to getting your CI/CD story implemented with flexibility. As an example, WSO2 API Cloud exposes Management REST APIs.
  • The ability to configure API testing tools such as Newman with your CI server is key to the success of your CI/CD solution. The quality of testing scripts determines the quality of your APIs.

Example of CI/CD for API Management

CI/CD for WSO2 API Cloud

In the above example, a microservice is exposed as a managed API in the WSO2 API Cloud.

  • The developer keeps updating the source code of the microservice implementation, the Swagger definition, Postman scripts, deployment scripts, etc.
  • Every time that developer pushes the changes to GitHub, Travis CI starts building the microservice implementation.
  • CI deploys the microservice into the WSO2 Integration Cloud and exposes that endpoint as a managed API in the WSO2 API Cloud.
    • In this particular example, CI does not deploy new versions, but, rather, updates the same version. However, you have the freedom to configure scripts to deploy new versions upon changes and deprecated previous API versions, etc., that are consuming the managed REST APIs.
  • CI runs the Postman scripts using Newman.
  • If all integration tests are successful in the dev environment, CI continues to deploy the microservice to staging runtime, perform testing, etc.
  • Try the above example.
  • Even if the above example makes use of GitHub, Travis, etc., you can configure it with any CI server.

Download A Buyer's Guide to Application and Data Integration, your one-stop-shop for research, checklists, and explanations for an application and data integration solution.

Topics:
ci/cd ,api management ,travis ci ,integration ,api integration

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}