项目作者: Axway-API-Management-Plus

项目描述 :
Axway APIM Pivotal Cloud Foundry Service Broker implementation
高级语言: Java
项目地址: git://github.com/Axway-API-Management-Plus/apim-service-broker.git
创建时间: 2019-01-28T19:32:57Z
项目社区:https://github.com/Axway-API-Management-Plus/apim-service-broker

开源协议:Apache License 2.0

下载


Build Status

Description

API Management Version Compatibility

This artifact successfully tested with following versions:

  • Axway AMPLIFY API Management 7.6.2 SP3 and v7.7.20200330
  • Pivtoal Platform - 2.6, 2.7, 2.8 and 2.9

Prerequisites

  • Axway AMPLIFY API Management 7.6.2 SP3 or above
  • JDK 1.8.0_xxx
  • Apache Maven 3.3.9 or above
  • Pivotal Cloud Foundry Elastic Runtime version 1.12 or above
  • CF Cli version 6.32.0+0191c33d9.2017-09-26 or above
  • Service Broker version 2.12 or above

Axway Service Broker Installation

  • Add a custom property to organizations

    Edit the following file:

    1. INSTALL_DIR/apigateway/webapps/apiportal/vordel/apiportal/app/app.config

    Insert the following code fragment marked in bold in the organizations property:

    1. customPropertiesConfig: {
    2. organization: {
    3. service_instance_id:{
    4. label: 'Service Instance Id'
    5. }
    6. },
    7. api: {
    8. cfBindingId:{
    9. label: 'Cloud Foundry Binding Id',
    10. permissions: {
    11. admin: { read: true, write: true, visible:true },
    12. oadmin: { read: true, write: false, visible:true },
    13. user: { read: true, write: false, visible:true }
    14. }
    15. }
    16. }
    17. }
  • Publish Server broker Application

    Check out the code from github

    1. $git clone https://github.com/Axway-API-Management-Plus/Cloud-Foundry-Service-Broker-Sample.git

    Build the project (output from cf push command provides fully qualified URL as output)

    1. $mvn clean package

    or you can use the following command if you want to skip testing step:

    1. $mvn clean package -Dmaven.test.skip=true

    Now, you can push your app to PCF:

    1. $cf push
    2. Showing health and status for app axway-apim-service-broker in org axwaydev / space dev as admin...
    3. OK
    4. requested state: started
    5. instances: 1/1
    6. usage: 1G x 1 instances
    7. urls: axway-apim-service-broker-nocuous-ovoviviparousness.cfapps.pie-25.cfplatformeng.com
    8. last uploaded: Wed Jan 3 21:35:47 UTC 2018
    9. stack: cflinuxfs2
    10. buildpack: client-certificate-mapper=1.2.0_RELEASE container-security-provider=1.8.0_RELEASE java-buildpack=v4.5-offline-https://github.com/cloudfoundry/java-buildpack.git#ffeefb9 java-main java-opts jvmkill-agent=1.10.0_RELEASE open-jdk-like-jre=1.8.0_1...
  • Create Service Broker

    1. $cf create-service-broker axway-apim-service-broker admin changeme http://axway-apim-service-broker-nocuous-ovoviviparousness.cfapps.pie-25.cfplatformeng.com --space-scoped
    2. Getting services from marketplace in org axwaydev / space dev as admin...
    3. OK

    Note: In the create-service-broker command, use an app URL shown in the output from the cf push command

  • Check whether the service broker is added in Pivotal market place

    1. $cf marketplace
    2. Getting services from marketplace in org axwaydev / space dev as admin...
    3. OK
    4. service plans description
    5. Axway-APIM APIM Axway service broker implementation
    6. app-autoscaler standard Scales bound applications in response to load
    7. p-circuit-breaker-dashboard standard Circuit Breaker Dashboard for Spring Cloud Applications
    8. p-config-server standard Config Server for Spring Cloud Applications
    9. p-mysql 100mb MySQL databases on demand
    10. p-rabbitmq standard RabbitMQ is a robust and scalable high-performance multi-protocol messaging broker.
    11. p-redis shared-vm, dedicated-vm Redis service to provide pre-provisioned instances configured as a datastore, running on a shared or dedicated VM.
    12. p-service-registry standard Service Registry for Spring Cloud Applications
    13. p.rabbitmq solo RabbitMQ Service
    14. p.redis cache-small Redis service to provide on-demand dedicated instances configured as a cache.
  • Add environment variables to Service Broker

    1. $cf set-env axway-apim-service-broker axway_apimanager_url https://myAPIM.server.com:8075
    2. $cf set-env axway-apim-service-broker axway_apimanager_username apiadmin
    3. $cf set-env axway-apim-service-broker axway_apimanager_password changeme
    4. $cf set-env axway-apim-service-broker axway_apimanager_traffic_url https://myAPIM.server.com:8065 // In High Availability scenario the URL will be a Load Balancer URL
    5. $cf set-env axway-apim-service-broker cf_admin_username admin@axway.com
    6. $cf set-env axway-apim-service-broker cf_admin_password changme
    7. $cf set-env axway-apim-service-broker api_host uaa.sys.industry.cf-app.com
    8. $cf set-env axway-apim-service-broker TRUST_CERTS uaa.sys.industry.cf-app.com //If your PCF instance uses self-signed certs, you may need to use this environment variable to prevent some security errors
  • Refresh Service Broker Instance to read the new environment variable

    1. $cf restage axway-apim-service-broker
  • Create Cloud Foundry Service to Bind and Unbind Routes

    1. $cf create-service Axway-APIM APIM-Free AxwayAPIM
    2. Creating service instance AxwayAPIM in org axwaydev / space dev as admin...
    3. OK

    Create service command does the following

  1. Fetch space name from Cloud controller and use it as organization name
  2. Create a new organization
  3. Fetch Cloud foundry login email id by calling Cloud Controller.
  4. Create a new User
  5. Reset password for the newly created user which triggers an email.

Axway Service Broker update

If any changes are made in the code base, publish the changes to Pivotal Elastic run time

  1. $cf push

Setup API Gateway

  1. Upload the following project in Axway Policy Studio

    • The Policy Studio Project (src/main/resources/apiproject) must be checked-out locally and imported into Policy Studio using the option Open Project.
  2. Deploy this project to your instance of Axway API Gateway. You may also export the Forward Request to API Manger Traffic Port policy from the project and import it in your API Gateway configuration. In addition, you will need to configure Gateway Listeners similar to how it is done in the provided project: port 8065 is mapped to the PCF listener, port 7070 is mapped to the API Manager Traffic listener.

Test Service Broker

  • Publish a target PCF application on Pivotal Cloud Foundry runtime
  • Add custom attribute in a json file (param.json)

    1. {
    2. "apiname": "pcftest",
    3. "type": "swagger",
    4. "uri": "/v2/api-docs"
    5. }

    apiName is optional. If apiName is not specified, Service broker fetch the API Name and from swagger or WSDL.
    Possible values of type paramters are wsdl and swagger
    The URI value will be context name or Fully qualified Swagger / WSDL URL (http://greeting-app2-unwrinkleable-carriole.cfapps.pie-25.cfplatformeng.com/v2/api-docs). If context name is provided as input, the service broker reads the host name from Cloud Foundry Application.

  • Run Route binding command

    1. $cf bind-route-service cfapps.pie-25.cfplatformeng.com AxwayAPIM --hostname greeting-app-tournois-postresurrection -c param.json

    The route binding command invokes Axway Service broker. The Service broker creates Backend, Front-End API using Pass-Through as inbound security.

  • Test the Pivotal Application

    Try to access your PCF application endpoint. To verify that the request goes through API Gateway, open Axway API Gateway Manager and look at the traffic tab. You should see two entries:

    • One comes from GoRouter (PCF) to API Gateway
    • The second one comes as a redirect from API Gateway itself

Axway Service Broker uninstallation

  • Unbind Route - Un-bind Application from Axway Service broker
  1. $cf unbind-route-service cfapps.pie-25.cfplatformeng.com AxwayAPIM --hostname greeting-app-tournois-postresurrection

The route unbinding command invokes Axway Service Broker and Service Broker does the following:

  1. If API is in Published state, it will throw an error.
  2. If API is in un-published state, delete front end API, backend API.
  • Delete Service
    1. $cf delete-service AxwayAPIM

Cloud Foundry delete service command does the following:

  1. If the service has binded application or routes, it throws an error.
  2. Delete Frontend and Backend APIs
  3. Delete applications
  4. Delete User
  5. Delete Organization
  • Delete Service Broker
    1. $cf delete-service-broker axway-apim-service-broker

Contributing

Please read Contributing.md for details on our code of conduct, and the process for submitting pull requests to us.

Team

alt text
Axway Team

License

Apache License 2.0