Install on Cloud Foundry

Install on Cloud Foundry
lac52
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:
 
 
3
 
 
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 
    CALiveAPICreator.war
     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 
    WEB-INF/lib
     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 
CALiveAPICreator.war
 file. The following commands are for UNIX, but the Windows commands are similar.
Prerequisite:
 You have a copy of the 
CALiveAPICreator.war
 file in the current directory.
  1. From terminal or a command prompt, create the 
    WEB-INF
     directory and the 
    WEB-INF/lib
     directory by issuing the following commands:
    mkdir WEB-INF
    mkdir WEB-INF/lib
  2. Download the JDBC driver from the web to the 
    WEB-INF/lib
     directory.
    wget -P WEB-INF/lib <JDBC driver file name and location on the web>
    Example:
     
    wget -P WEB-INF/lib http://central.maven.org/maven2/mysql/mysql-connector-java/8.0.12/mysql-connector-java-8.0.12.jar
  3. Add the JAR file to the 
    /development/CALiveAPICreator.war
     file by issuing the following command:
    jar uvf CALiveAPICreator.war WEB-INF/lib/<JDBC driver file name>
    Example:
     
    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 
push
 command with the following options:
cf push MyLiveAPICreator -p CALiveAPICreator.war -b https://github.com/cloudfoundry/java-buildpack.git
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
routes: myliveapicreator.cfapps.io
last uploaded: Wed 05 Sep 11:54:32 PDT 2018
stack: cflinuxfs2
buildpacks: https://github.com/cloudfoundry/java-buildpack.git
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 -Djava.io.tmpdir=$TMPDIR
-Djava.ext.dirs=$PWD/.java-buildpack/container_security_provider:$PWD/.java-buildpack/open_jdk_jre/lib/ext
-Djava.security.properties=$PWD/.java-buildpack/java_security/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 &&
JAVA_OPTS="$JAVA_OPTS $CALCULATED_MEMORY" && MALLOC_ARENA_MAX=2 JAVA_OPTS=$JAVA_OPTS JAVA_HOME=$PWD/.java-buildpack/open_jdk_jre exec
$PWD/.java-buildpack/tomcat/bin/catalina.sh 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 
manifest.yml
 file.
Follow these steps:
 
  1. Define a 
    manifest.yml
     file.
    The following code snippet shows an example of the contents of a 
    manifest.yml
     file, with the options added as environment variables:
    ---
    applications:
    - 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
    env:
    ca_accept_license: ENU
    LAC_INITIAL_SA_PASSWORD: Password2
    LAC_INITIAL_ADMIN_PASSWORD: Password3
    LAC_INITIAL_ACCOUNT_URL_NAME: myteamspace
    LAC_INITIAL_ACCOUNT_NAME: MyTeamSpace
    LAC_SERVER_IDENT: MyPCFserver
    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 
CA_ACCEPT_LICENSE
 option as an environment variable or as a Java system property, for example:
CA_ACCEPT_LICENSE: ENU
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 
LAC_DEFAULT_LICENSE_FILE
 option when you start API Server:
LAC_DEFAULT_LICENSE_FILE
Example:
 
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 (
sa
) 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 
LAC_INITIAL_SA_PASSWORD
 and the 
LAC_INITIAL_ADMIN_PASSWORD
 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 
LAC_REPOSITORY_ROOT
 option. You can change this location by adding the 
LAC_REPOSITORY_CONFIGURATION_URL
 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 
LAC_REPOSITORY_ROOT
 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 
    http://myliveapicreator.cfapps.io
    , 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]
    OK
    name requested state instances memory disk urls
    MyLiveAPICreator started 1/1 1G 1G myliveapicreator.cfapps.io
  3. Verify that all is well by looking at the logs by issuing the following command:
    cf logs --recent MyLiveAPICreator
Configure 
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 
LAC_DEFAULT_LICENSE_FILE
 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.