Cloud Foundry CLI Integration

The Cloud Foundry (CF) CLI (Command Line Interface) integration is also Digital.ai Deploy integration for the CloudFoundry server which makes use of CF CLI.

This document describes how CF CLI integration is used in the Digital.ai Deploy server.

Install the CF CLI Plugin

To install the CF CLI plugin, refer Plug Manager Documentation:

Features

The Cloud Foundry CLI Integration supports:

  • Creating spaces
  • Deploying Cloud Foundry applications
  • Creating routes for a Cloud Foundry application
  • Binding services with a Cloud Foundry application
  • Creating Cloud Foundry services
  • Deploying Cloud Foundry application using a manifest file

Create an Infrastructure

  1. In the side navigation bar, click Explorer.
  2. Hover over Infrastructure, click Context menu, then select New > cf > Organization. A new tab displays. image
  3. Specify the following properties in the cf.organization:
  4. Organization Name: Organization name on the Cloud Foundry server
  5. API Endpoint: API endpoint of Cloud Foundry server
  6. Cf Home: Location where the oc client can be found
  7. Default Space Name: Add any default space which we use while 1st login using cf cli
  8. Cli Version: Select CLI version installed on system
  9. Username: User name to use for authentication
  10. Password: Password to use for authentication.
  11. Click on Save Create Infrastructure
  12. Hover over newly created cf.organization, click Context menu, then Check Connection.
  13. Click Execute and check the connection.

Add Space in Infrastructure

To add Space in cf.organization infrastructure, do the following steps:

  1. Hover over the newly created cf.organization, click Context menu, then select New > cf > Space. A new tab displays.
  2. Specify the space name in the Name field.
  3. Click Save

Note: You can also add Space to organization by creating space app and deploy it to cf.organization.

Add Space in CF

Create an Environment

To create an environment, do the following steps:

  1. In the side navigation bar, click Explorer.
  2. Hover over Environments, click Context menu, then select New > Environment. A new tab displays.
  3. In the Name field, enter a name for the environment.
  4. In the Common section, click Containers field and select newly created cf.organization or Space containers.
    Note: You have to create two environments, one for Organization and the other for Space.
  5. Click Save.

image

image

Note: cf.organization will be the container for SpaceSpec which deploys Space will be the container for the other (pushApp, Manifest, Routes, Service) deployment.

Create and Deploy an Application

The following are the deploy tasks that can be performed:

  1. cf.SpaceSpec: Deploys a Space to an Organisation environment (env that has cf.organization container).
  2. cf.PushAppSpec: Deploys or push an App to a Space environment (env that has cf.Space container deployed by cf.SpaceSpec deployable).
  3. cf.ManifestModuleSpec: Deploy Multiple applications using a single manifest file to Space environment (env that has cf.Space container deployed by cf.SpaceSpec deployable).
  4. cf.RouteSpec: Deploys a Route to a Space environment.
  5. 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 required properties for Space.

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. Click Save.
  2. Deploy the SpaceSpec to cf.organization container environment.

image

Deploy or Push an App

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

  1. Create a deployment package and specify the deployable (any artifact file like war, jar or zip) as PushAppSpec.
  2. Specify the required properties 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 PushAppSpec are specific to v7 of CF CLI.
  4. To deploy the artifact file to CF, create a PushAppSpec with the App name, buildback and memory- 1G. Then deploy it to a CF.
  5. For rolling deployment, select the strategy as rolling, while creating the deployment package. image
  6. After creating the cf.PushAppSpec deployable, you can deploy its package to the environments containing Space infrastructure container. image Note: You can update this deployment and undeploy.
    Note: You cannot change the appName of pushed app as it uniquely identifies the name of an App during the update process.

Deploy or Push and app using ManifestFile

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

  1. Create a deployment package and specify the deployable as ManifestModuleSpec.
  2. In the File property, specify a zip file that contains the manifest file and artifacts required to create the application.
  3. If you want to deploy the app with a sidecar process then you have to put information related to sidecar in the manifest.yml file.
  4. You can also update this deployment and undeploy.
  5. After the creation of cf.ManifestModuleSpec deployable, you can deploy its package to environments containing a Space infrastructure container. image Note: As per cloudfoundry cli document we cannot use any command line options with cf push except for -f and --no-start. Hence if the user wants to make any configuration for application in multi-app deployment then configuration has to be add in the manifest file instead of in xld

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, that shows the command 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 properties of the 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.Organization deployed

The cf.Organization control task will list all Spaces in the current CF servers.

On cf.App deployed:

The following are the control tasks that can be performed on cf.PushApp 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: Stops the running App in Cloud Foundry Space

  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 on 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 control tasks that can be performed on 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.