Cloud Foundry CLI Integration

The Cloud Foundry (CF) CLI (Command Line Interface) is the official command line client for Cloud Foundry server. You can use the CF CLI to manage apps, service instances, orgs, spaces, and users in your environment.

Install the CF CLI Plugin

To download the CF CLI plugin, do the following steps:

  1. Open the Distribution site.
  2. Download the CF CLI plugin with .xldp extension at XLDEPLOYSERVER_HOME/plugins/ directory.
  3. Restart the Deploy

Features

  • Create an Infrastructure
  • Creating an Environment
  • Create and Deploy an Application

    • Deploy a Space
    • Deploy or Push an App
    • Deploy a Route
    • Deploy a Service
  • Controls tasks

Create an Infrastructure

  1. Create an overthere host in Infrastructure where CF CLI is installed.
  2. Create a new cf client (cf.Client) under the overthere host. image
  3. Specify the properties related to the CF CLI client like username, password, apiEndpoint, CLI version, binary home, tls, etc. image
  4. Under the cf.Client container, create a new Org (organisation (cf.Org)). image
  5. Specify the properties of the Org like orgName and CI name.

Note: You can create multiple Org container CIs if you want to map other Orgs in different Deploy’s environments.

  1. Specify the Org that you want to use in the orgToUse property under the cf.Client image
  2. This cf.Org will be the container for deploying Space and Space will be the container for deploying other deployable like Pushed App, Routes, and Services.
  3. Create an environment of the cf.Org

Create an Environment

To create an environment, do the following steps:

Note: You can create environment in each Org.

Create an Environments using Org and specify the properties shown in below image. image

Note: cf.Org will be the container for cf.SpaceSpec which deploys cf.Space container and cf.Space will be the container for other the deplorables.

Create and Deploy an Application

The following are the four deploy tasks that can be performed:

  1. cf.SpaceSpec: Deploys a Space to an Org (Organisation) environment (that has cf.Org container).
  2. cf.PushSpec: Deploys or push an App to a Space environment (env that has cf.Space container deployed by cf.SpaceSpec deployable).
  3. cf.RouteSpec: Deploys a Route to a Space environment.
  4. cf.ServiceSpec: Deploy a Service to a Space environment.

image

Note: If you have multiple spaces in a single Org, it is advised to create a separate Environment which has a container reference to a single Space.

Deploy a Space

To deploy a space, do the following steps:

  1. Create a deployment package and specify the deployable as SpaceSpec.
  2. Specify the properties that you want for Space as shown in below image.

Note: You must have to provide already available space name in Default Space Name property as your initial default space while login into cf CLI. image

  1. Select the desired environment containing Org and deploy to it. image
  2. After creating a Space, you can verify that the Space and Org are bound to the same environment. This is important as all other deployable are deployed to cf.Space container.

Deploy or Push an App

To deploy or push an App, do the following steps:

  1. Create a deployment package and specify the deployable as PushSpec.
  2. Specify the properties that you want for Push.
  3. The properties of Pushing an App in Deploy are similar as mentioned in https://cli.cloudfoundry.org/en-US/v6/push.html and https://cli.cloudfoundry.org/en-US/v7/push.html.

Note: Only some properties in PushSpec are specific to v7 of CF CLI.

  1. The push artifacts such as zip file of project (-p option), manifest file (-f option) and variables files (--var-file option) is also supported for PushSpec as children artifacts as types- cf.AppZip, cf.ManifestFile, and cf.VarFile. image
  2. AppZip is a zip containing the apps with the corresponding manifest file in the root of a zip file. The file can be a war, jar, zip, or any artifact file.
  3. To deploy the war file to CF, create a PushSpec with the App name, buildback- https://github.com/cloudfoundry/java-buildpack.git and memory- 1G. Then deploy it to a Space environment.
  4. ManifestFile is the manifest to deploy the artifact in CF (Instead of manifest the Push options in PushSpec can also be given as the option in Manifest and Push Options are the same).

Note: Please do not specify the app name in the manifest.yml file as it is being supplied from the PushSpec’s property appName. Make sure not to supply different options (specifying the same options in manifest.yml and Push Options of PushSpec).

  1. VarFile is a file that container the entries for variable substitution for ManifestFile.
  2. The maximum of AppZip and ManifestFile artifacts are limited to 1, where as you can supply as multiple VarFile artifacts.
  3. For rolling deployment you have to select the strategy as rolling while creating deployment package. image
  4. If you want to push app with sidecar process, then you have to put information related to sidecar in manifest.yml file. image
  5. After the creation of cf.App deployable, you can deploy its package to the environments containing Space infrastructure container. image
  6. You can also update this deployment and un-deploy. image
  7. You cannot change the appName of Pushed App as it uniquely identifies the name of an App during the update process.

How to verify the CF CLI command on XLD before executing the task?

To verify the CF CLI command before executing, do the following steps:

  1. After you select the deployable for deployment of app click on Preview. image
  2. Double click on any step, will show the command that will be run on CF CLI.
    image

Deploy a Route

To deploy a Route, do the following steps:

  1. Create a deployment package with deployable cf.RouteSpec.
  2. Specify the properties of RouteSpec.
  3. Specify a Valid Route Domain. There are special properties that correspond to routeType http or tcp. image
  4. After the creation of deployable, you can deploy its package to the Space Environment.
  5. Deploy, Update and Un-deployment of a Route is supported.

Deploy a Service

To deploy a service, do the following steps:

  1. Add service to your targeted Organization. Refer Managing Services.
  2. Create a deployment package with deployable cf.ServiceSpec.
  3. Specify the properties of ServiceSpec.
  4. Specify service to use, plan, and service instance. You can also use options like specify broker, configuration (JSON string), and Service Tags.
  5. There are upgrade-specific options under the category update options also which need to be given only in case of updating a service.
  6. You cannot change service instance or service while updating the service as these are the properties that identify a service uniquely. image
  7. After the creation of deployable, you can deploy its package to the Space Environment.
  8. Deploy, Update and Un-deployment of a Service is supported.

Controls Tasks

There are a number of control tasks that you can perform using cloudfoundry-cli-integration.

On cf.Org deployed

The following control task that can be performed cf.Org deployed:

  1. List all Organizations:

    This control task will list all the organizations in the current CF servers. Supply the space name as a parameter to this control task to support login.
    image

On cf.App deployed:

The following are the four control tasks that can be performed cf.App deployed:

image

  1. Restart the App:

    Note” Restarts the running App in Cloud Foundry Space. There are params you can supply if the deployment is like strategy and no wait. The strategy should be specified if a deployment is rolling update.

  2. Stop the App

    Note: Stop the App:

  3. Start the App

    Note: Starts the stopped App in Cloud Foundry Space.

  4. Scale the App:

    Note: Scales the currently running App on the ground of instances, disk limit, and memory limit.

image

On cf.Route deployed

The following control task that can be performed cf.Route deployed:

image

  1. Map Route:

    Note: Maps the current route(deployed) to an instance of an App. Supply the App name in the control task parameter and this control task will map the deployed route to an App.

On cf.Service deployed

The following are the four control tasks that can be performed cf.Service deployed:

  1. bindService:

    Note:Bind this service instance (deployed) to an app. Supply parameters- App Name, bindingName, and conf (configuration in JSON string) to this control task.

  2. unbindService:

    Note:Unbind this service instance (deployed) from an app. Supply parameters- App Name to this control task.

  3. bindRouteService:

    Note:Bind this service instance (deployed) to an HTTP route. Supply parameters- domain, hostname, path, and conf (configuration in JSON string) to this control task.

  4. unbindRouteService:

    Note:unbind this service instance (deployed) to an HTTP route. Supply parameters- domain, hostname, and path to this control task.