Install on Cloud Foundry

Install on Cloud Foundry
You can install 
Layer7 Live API Creator
 in a Cloud Foundry environment. The following examples use the public Pivotal Cloud Foundry, but you can also run in a private cloud.
For more information about Pivotal Cloud Foundry, see the Pivotal Cloud Foundry website.
In this article:
Verify the Prerequisites
Before you install 
Layer7 Live API Creator
 on Cloud Foundry, ensure that you have completed the following prerequisite steps:
  • You have installed the Cloud Foundry command line, and you are logged in to Cloud Foundry.
  • You have obtained the package containing the 
     web application ARchive (WAR) file. You use this WAR file to install in a Cloud Foundry environment. This file only includes the JDBC driver for Derby. If you plan to access other database types, such as MySQL, PostgreSQL, Oracle, IBM Db2, or Microsoft SQL Server, add the JDBC driver for that database type to the WAR file (in the 
     directory), or make them available to the app in Cloud Foundry.
  • You know which license type you are using 
    Layer7 Live API Creator
     under, either a standard license that the CA Support site issues or an Enterprise Software Portfolio License Agreement (PLA).
    For more information about licensing, see Licensing.
(Optional) Add JDBC Drivers and Other Libraries into the WAR File
You can enable access to a database by adding the JDBC driver for that database into the 
 file. The following commands are for UNIX, but the Windows commands are similar.
 You have a copy of the 
 file in the current directory.
  1. From terminal or a command prompt, create the 
     directory and the 
     directory by issuing the following commands:
    mkdir WEB-INF
    mkdir WEB-INF/lib
  2. Download the JDBC driver from the web to the 
    wget -P WEB-INF/lib <JDBC driver file name and location on the web>
    wget -P WEB-INF/lib
  3. Add the JAR file to the 
     file by issuing the following command:
    jar uvf CALiveAPICreator.war WEB-INF/lib/<JDBC driver file name>
    jar uvf CALiveAPICreator.war WEB-INF/lib/mysql-connector-java-8.0.12.jar
  4. Add other JDBC drivers and Java libraries as needed.
The WAR file now contains the JDBC drivers and other Java libraries. The file is ready for you to install it in a Cloud Foundry environment.
Deploy as Cloud Foundry Application
You can deploy Cloud Foundry applications using several methods. The following example illustrates a method that uses options for basic Cloud Foundry application deployment.
For more information:
Follow this step:
Issue the 
 command with the following options:
cf push MyLiveAPICreator -p CALiveAPICreator.war -b
The following output is expected:
Uploading droplet, build artifacts cache...
Uploading droplet...
Uploading build artifacts cache...
Uploaded build artifacts cache (55.1M)
Uploaded droplet (125.8M)
Uploading complete
Waiting for app to start...
Cell a39a5e3a-75de-4118-1041-9e2be7c61825 stopping instance 8afcfd14-603f-498b-a699-ca4d4d82a2bd
Cell a39a5e3a-75de-4118-1041-9e2be7c61825 destroying container for instance 8afcfd14-603f-498b-a699-ca4d4d82a2bd
name: MyLiveAPICreator
requested state: started
last uploaded: Wed 05 Sep 11:54:32 PDT 2018
stack: cflinuxfs2
type: web
instances: 1/1
memory usage: 1024M
start command: JAVA_OPTS="-agentpath:$PWD/.java-buildpack/open_jdk_jre/bin/jvmkill-1.16.0_RELEASE=printHeapHistogram=1$TMPDIR
-Djava.ext.dirs=$PWD/.java-buildpack/container_security_provider:$PWD/.java-buildpack/open_jdk_jre/lib/ext$PWD/.java-buildpack/java_security/ $JAVA_OPTS -Daccess.logging.enabled=false -Dhttp.port=$PORT" &&
CALCULATED_MEMORY=$($PWD/.java-buildpack/open_jdk_jre/bin/java-buildpack-memory-calculator-3.13.0_RELEASE -totMemory=$MEMORY_LIMIT
-loadedClasses=23031 -poolType=metaspace -stackThreads=250 -vmOptions="$JAVA_OPTS") && echo JVM Memory Configuration: $CALCULATED_MEMORY &&
$PWD/.java-buildpack/tomcat/bin/ run
state since cpu memory disk
#0 running 2018-09-05T18:55:15Z 251.0% 349.6M of 1G 262.1M of 1G
Next Steps
Complete the following procedures after you have created and uploaded the Cloud Foundry application.
Enable Other Options at Server Startup
The following are options that you can enable at startup:
 Add these options before starting your server only once. Do not add these options as part of normal operations.
For more information:
You can enable the options when you start API Server by way of a defined 
Follow these steps:
  1. Define a 
    The following code snippet shows an example of the contents of a 
     file, with the options added as environment variables:
    - name: MyLiveAPICreator
    instances: 1
    memory: 768M
    buildpack: java_buildpack
    path: CALiveAPICreator.war
    health-check-type: http
    health-check-http-endpoint: /rest/abl/admin/v2/@heartbeat
    ca_accept_license: ENU
    LAC_REPOSITORY_ROOT: /tmp/repo
  2. Add the file to the same directory as the WAR file.
  3. Create and upload the Cloud Foundry application.
    For more information, see the "Create and Upload the Cloud Foundry Application" section.
Bypass the Extra Step at Login to Accept the EULA
If you are deploying into production using a cluster or if you are scripting deployment, you can bypass the API Creator screen that asks the initial API developer (a TeamSpace user) to log in to accept the user license, which pre-accepts the terms of the EULA. You can pre-accept the terms of the EULA by adding the 
 option as an environment variable or as a Java system property, for example:
Specify an Alternate License File
If you are licensed to use 
Layer7 Live API Creator
 under the standard license that the CA Support site issues, the first time that you start 
Layer7 Live API Creator
 in Cloud Foundry, you must install the API Server license file. You can install this file when you start your Cloud Foundry environment by adding the 
 option when you start API Server:
LAC_DEFAULT_LICENSE_FILE: /Users/jdoe/License.txt
Change the Initial Password for the System Administrator User and for the Initial API Developer
If you did not change the passwords for the system administrator (
) user and for the initial API developer (a TeamSpace user) for the default TeamSpace as options when you started your Java container, change the passwords. Add the 
 and the 
 options when you start API Server.
For more information:
Specify the Location from Where you Want 
Layer7 Live API Creator
 to Pull your Admin Repository
By default, at initial server startup, 
Layer7 Live API Creator
 pulls your admin repository from the location you set using the 
 option. You can change this location by adding the 
 option when you start API Server.
Specify the Location to Where you Want 
Layer7 Live API Creator
 to Add your Admin Repository
The first time that you start your Cloud Foundry environment with 
Layer7 Live API Creator
, you must set the location for your admin repository at startup by adding the 
 option when you start API Server, for example:
LAC_REPOSITORY_ROOT: /var/lib/repository
You can change the location using this option.
Connect to your Installation
  1. Connect to your installation, in this example
    , and then log in.
  2. Verify that 
    Layer7 Live API Creator
     is up by issuing the following command:
    cf apps
    The following output is expected:
    Getting apps in org acme / space development as [email protected]
    name requested state instances memory disk urls
    MyLiveAPICreator started 1/1 1G 1G
  3. Verify that all is well by looking at the logs by issuing the following command:
    cf logs --recent MyLiveAPICreator
Layer7 Live API Creator
 to Collect and Send Usage Data
If you are licensed to use 
Layer7 Live API Creator
 under a PLA, you must activate 
Layer7 Live API Creator
 and configure it to collect and send usage data. If you are licensed to use 
Layer7 Live API Creator
 under a standard license, you can consent to 
Layer7 Live API Creator
 collecting and sending usage data.
For more information about how to configure to collect and send usage data, see Activate and Configure to Send Usage Data.
Import the API Server License
The API Server license controls access to API Creator and services. If you are licensed to use 
Layer7 Live API Creator
 under a standard license and you did not specify a license file when starting your Cloud Foundry environment (by adding the 
 option at Cloud Foundry startup), you must now upload it.
For more information about licensing, see Licensing.
Advanced Configuration
The following topic provides advanced configuration details.
Create a Database for your Authentication Tokens
By default, 
Layer7 Live API Creator
 generates authentication tokens, stores them in the in-memory Derby database, and synchronizes them to your admin repository in the following cases:
  • You have configured 
    Layer7 Live API Creator
     to run as a single node.
  • You are running in a local development environment.
  • You have specified an authentication provider that uses the 
    Default Auth Provider
     authentication method (for example, the 
    built-in authentication
     authentication provider) or a custom JavaScript authentication provider that uses the 
    JavaScript Auth Provider
     authentication method as the authentication provider for your API.
You can optionally have 
Layer7 Live API Creator
 store the authentication tokens that it generates for API users in a database instead by creating one.
For more information about how to create this database, see Create a Database for your Authentication Tokens.