# Cloud Foundry

## Configuration

### Adding PCF Cloud From Infrastructure > Clouds

#### Procedure

1. Navigate to Infrastructure  >  Clouds
2. Select + ADD
3. Select CLOUD FOUNDRY from the Clouds list
4. Select NEXT
5. Populate the following: 

   Cloud Configuration

   NAME
   :   Name of the Cloud in HPE Morpheus Enterprise

   CODE
   :   Unique code used for api/cli, automation and policies.

   LOCATION
   :   Description field for adding notes on the cloud, such as location.

   VISIBILITY
   :   For setting cloud permissions in a multi-tenant environment. Not applicable in single tenant environments.

   TENANT
   :   If Visibility is set to Private, select the Tenant the Cloud resources will assigned to.

   ENABLED
   :   When disabled, automatic Cloud sync is paused and the Cloud will not be selectable for provisioning.

   AUTOMATICALLY POWER ON VMS
   :   When enabled, HPE Morpheus Enterprise will maintain the expected power state of managed VMs. HPE Morpheus Enterprise will power on any managed VMs in the Cloud that have been shut down for unknown reasons (not powered off by HPE Morpheus Enterprise) to ensure availability of services.

       NOTE

       When “AUTOMATICALLY POWER ON VMS” is enabled, the power state of managed VMs should be maintained in HPE Morpheus Enterprise. This setting is not applicable to discovered/unmanaged resources.

   Details

   API URL
   :   Cloud Foundry API Url

   CLIENT ID
   :   Typically `cf`

   CLIENT SECRET
   :   Typically blank

   USERNAME
   :   Enter Username. If using an API Key, enter `apikey` for username, and the API Key as the password.

   PASSWORD
   :   Enter Password. If using an API Key, the API Key as the password.

   ORGANIZATION
   :   Select Organization. Dropdown populates upon successful authorization.

   Advanced Options

   DOMAIN
   :   Specify a default domain for instances provisioned to this Cloud.

   SCALE PRIORITY
   :   Only affects Docker Provisioning. Specifies the priority with which an instance will scale into the cloud. A lower priority number means this cloud integration will take scale precedence over other cloud integrations in the group.

   APPLIANCE URL
   :   Alternate Appliance url for scenarios when the default Appliance URL (configured in admin  >  settings) is not reachable or resolvable for Instances provisioned in this cloud. The Appliance URL is used for Agent install and reporting.

   TIME ZONE
   :   Configures the time zone on provisioned VM’s if necessary.

   DATACENTER ID
   :   Used for differentiating pricing among multiple datacenters. Leave blank unless prices are properly configured.

   NETWORK MODE
   :   Unmanaged or select a Network Integration (NSX, ACI etc)

   LOCAL FIREWALL
   :   On or Off. Enable to managed Host and VM firewall/IP Table rules (linux only)

   SECURITY SERVER
   :   Security Server setting is for Security Service Integrations such as ACI

   TRUST PROVIDER
   :   Select Internal (Morpheus) or an existing Trust Provider Integration

   STORAGE MODE
   :   Single Disk, LVM or Clustered

   BACKUP PROVIDER
   :   Select a backup provider. Depending on the Cloud type and any currently-configured backup plugins you may select Internal Backups (Morpheus) or another configured backup solution

   REPLICATION PROVIDER
   :   Sets the default Replication Provider for the Cloud. Select an existing Replication Provider Integration

   GUIDANCE
   :   Enable Guidance recommendations on cloud resources.

   COSTING
   :   Enable for HPE Morpheus Enterprise to sync Costing data from the Cloud provider, when available. For on-prem Clouds, enabling costing activates a costing service designed to mirror the live costing experience of public clouds, including invoicing with line items and real-time cost data (Operations > Costing > Invoices). If your organization utilizes reserved instances and you want to pull in related pricing data, some Cloud integrations include the option to select Costing and Reservations. If this is not relevant, select Costing to save money on additional calls to the Cloud provider’s costing API.

   DNS INTEGRATION
   :   Records for instances provisioned in this cloud will be added to selected DNS integration.

   SERVICE REGISTRY
   :   Services for instances provisioned in this cloud will be added to selected Service Registry integration.

   CONFIG MANAGEMENT
   :   Select a Chef, Ansible or Puppet integration to be used with this Cloud.

   CMDB
   :   Select CMDB Integration to automatically update selected CMDB.

   CMDB DISCOVERY
   :   When checked, any automatically discovered (unmanaged) servers onboarded into HPE Morpheus Enterprise from this Cloud will also have CMDB records created for them.

   CHANGE MANAGEMENT
   :   Select an existing Change Management Integration to set on the Cloud. ex: Cherwell

   AGENT INSTALL MODE
   :   - SSH / WINRM / Guest Execution: HPE Morpheus Enterprise will attempt to use SSH, WINRM or Guest Execution for Agent install.
       - Cloud Init / Unattend (when available): (DEFAULT) HPE Morpheus Enterprise will utilize Cloud-Init or Cloudbase-Init for agent install when provisioning images with Cloud-Init/Cloudbase-Init installed. HPE Morpheus Enterprise will fall back on SSH or WINRM if cloud-init is not installed on the provisioned image. Morpheus will also add Agent installation to Windows unattend.xml data when performing Guest Customizations or utilizing syspreped images.

   VDI GATEWAY
   :   Set a VDI Gateway for outbound communication from the HPE Morpheus Enterprise Appliance to the vdi endpoints. VDI Gateways can be added in `/tools/vdi/gateways`

   CUSTOM LOGOS

   When integrating a Cloud, it will appear by default throughout the UI with its standard logo (VMware logo for VMware Clouds, etc.). If desired, you may upload a custom logo that should appear instead. This might be useful for MSPs which might not want to reveal the Cloud type underlying its services. A dark mode version of the logo may also be uploaded if the standard logo doesn’t look right against the HPE Morpheus Enterprise dark mode theme. Checking USE DEFAULT CLOUD LOGOS allows the user to return to the standard logo for the Cloud type without deleting the custom uploaded logo.

   INVENTORY OPTIONS

   Inventory options allow you to set a default active or inactive state for certain discovered resources. The list of available resources to configure will vary based on the Cloud type and its supported resources. By default, all possible resources for the Cloud type will be discovered in an active state. Uncheck the box for some or all resources to discover them in an inactive state. The list of potential resources that may appear include:

   - Service Plans
   - Resource Pools
   - Networks
   - Security Groups
   - Datastores
   - Folders

   Provisioning Command

   PROXY
   :   Set a proxy for inbound communication from Instances to the HPE Morpheus Enterprise Appliance. Proxies can be added in the Infrastructure  >  Networks  >  Proxies tab.

   Bypass Proxy for Appliance URL
   :   Enable to bypass proxy settings (if added) for HPE Morpheus Enterprise Agent communication to the Appliance URL.

   NO PROXY
   :   Include a list of IP addresses or name servers to exclude from proxy traversal

   USER DATA (LINUX)
   :   Add cloud-init user data. HPE Morpheus Enterprise 4.1.0 and earlier assumes bash syntax. HPE Morpheus Enterprise 4.1.1 and later supports all User Data formats. Refer to <https://cloudinit.readthedocs.io/en/latest/topics/format.html> for more information.
6. Select NEXT
7. Select an existing or create a new Group to add the Cloud to. The Cloud can be added to additional Groups in a Groups Clouds tab.
8. Select NEXT
9. Review and then Select COMPLETE

### Adding PCF Cloud From Infrastructure > Groups

#### Procedure

1. Navigate to Infrastructure  >  Groups
2. Select a Group
3. Select the CLOUDS tab
4. Scroll down to CLOUD FOUNDRY and select + ADD
5. Populate the following: 

   Name
   :   Name of the Cloud in HPE Morpheus Enterprise

   Location
   :   Description field for adding notes on the cloud, such as location.

   Visibility
   :   For setting cloud permissions in a multi-tenant environment. Not applicable in single tenant environments.

   TENANT
   :   Select a Tenant if Visibility is set to Private to assign to Cloud to that Tenant. Multiple Tenants can be added by editing the cloud after creation.

   API URL
   :   Cloud Foundry API Url. Example `https://api.cf.morpheusdata.com`

   CLIENT ID
   :   Typically `cf`

   CLIENT SECRET
   :   Typically blank

   USERNAME
   :   Enter Username. If using an API Key, enter `apikey` for username, and the API Key as the password.

   PASSWORD
   :   Enter Password. If using an API Key, the API Key as the password.

   ORGANIZATION
   :   Select Organization. Dropdown populates upon successful authorization.

   Advanced Options

   DOMAIN
   :   Specify a default domain for instances provisioned to this Cloud.

   SCALE PRIORITY
   :   Only affects Docker Provisioning. Specifies the priority with which an instance will scale into the cloud. A lower priority number means this cloud integration will take scale precedence over other cloud integrations in the group.

   APPLIANCE URL
   :   Alternate Appliance url for scenarios when the default Appliance URL (configured in admin  >  settings) is not reachable or resolvable for Instances provisioned in this cloud. The Appliance URL is used for Agent install and reporting.

   TIME ZONE
   :   Configures the time zone on provisioned VM’s if necessary.

   DATACENTER ID
   :   Used for differentiating pricing among multiple datacenters. Leave blank unless prices are properly configured.

   NETWORK MODE
   :   Unmanaged or select a Network Integration (NSX, ACI etc)

   LOCAL FIREWALL
   :   On or Off. Enable to managed Host and VM firewall/IP Table rules (linux only)

   SECURITY SERVER
   :   Security Server setting is for Security Service Integrations such as ACI

   TRUST PROVIDER
   :   Select Internal (Morpheus) or an existing Trust Provider Integration

   STORAGE MODE
   :   Single Disk, LVM or Clustered

   BACKUP PROVIDER
   :   Select a backup provider. Depending on the Cloud type and any currently-configured backup plugins you may select Internal Backups (Morpheus) or another configured backup solution

   REPLICATION PROVIDER
   :   Sets the default Replication Provider for the Cloud. Select an existing Replication Provider Integration

   GUIDANCE
   :   Enable Guidance recommendations on cloud resources.

   COSTING
   :   Enable for HPE Morpheus Enterprise to sync Costing data from the Cloud provider, when available. For on-prem Clouds, enabling costing activates a costing service designed to mirror the live costing experience of public clouds, including invoicing with line items and real-time cost data (Operations > Costing > Invoices). If your organization utilizes reserved instances and you want to pull in related pricing data, some Cloud integrations include the option to select Costing and Reservations. If this is not relevant, select Costing to save money on additional calls to the Cloud provider’s costing API.

   DNS INTEGRATION
   :   Records for instances provisioned in this cloud will be added to selected DNS integration.

   SERVICE REGISTRY
   :   Services for instances provisioned in this cloud will be added to selected Service Registry integration.

   CONFIG MANAGEMENT
   :   Select a Chef, Ansible or Puppet integration to be used with this Cloud.

   CMDB
   :   Select CMDB Integration to automatically update selected CMDB.

   CMDB DISCOVERY
   :   When checked, any automatically discovered (unmanaged) servers onboarded into HPE Morpheus Enterprise from this Cloud will also have CMDB records created for them.

   CHANGE MANAGEMENT
   :   Select an existing Change Management Integration to set on the Cloud. ex: Cherwell

   AGENT INSTALL MODE
   :   - SSH / WINRM / Guest Execution: HPE Morpheus Enterprise will attempt to use SSH, WINRM or Guest Execution for Agent install.
       - Cloud Init / Unattend (when available): (DEFAULT) HPE Morpheus Enterprise will utilize Cloud-Init or Cloudbase-Init for agent install when provisioning images with Cloud-Init/Cloudbase-Init installed. HPE Morpheus Enterprise will fall back on SSH or WINRM if cloud-init is not installed on the provisioned image. Morpheus will also add Agent installation to Windows unattend.xml data when performing Guest Customizations or utilizing syspreped images.

   VDI GATEWAY
   :   Set a VDI Gateway for outbound communication from the HPE Morpheus Enterprise Appliance to the vdi endpoints. VDI Gateways can be added in `/tools/vdi/gateways`

   CUSTOM LOGOS

   When integrating a Cloud, it will appear by default throughout the UI with its standard logo (VMware logo for VMware Clouds, etc.). If desired, you may upload a custom logo that should appear instead. This might be useful for MSPs which might not want to reveal the Cloud type underlying its services. A dark mode version of the logo may also be uploaded if the standard logo doesn’t look right against the HPE Morpheus Enterprise dark mode theme. Checking USE DEFAULT CLOUD LOGOS allows the user to return to the standard logo for the Cloud type without deleting the custom uploaded logo.

   INVENTORY OPTIONS

   Inventory options allow you to set a default active or inactive state for certain discovered resources. The list of available resources to configure will vary based on the Cloud type and its supported resources. By default, all possible resources for the Cloud type will be discovered in an active state. Uncheck the box for some or all resources to discover them in an inactive state. The list of potential resources that may appear include:

   - Service Plans
   - Resource Pools
   - Networks
   - Security Groups
   - Datastores
   - Folders

   Provisioning Command

   PROXY
   :   Set a proxy for inbound communication from Instances to the HPE Morpheus Enterprise Appliance. Proxies can be added in the Infrastructure  >  Networks  >  Proxies tab.

   Bypass Proxy for Appliance URL
   :   Enable to bypass proxy settings (if added) for HPE Morpheus Enterprise Agent communication to the Appliance URL.

   NO PROXY
   :   Include a list of IP addresses or name servers to exclude from proxy traversal

   USER DATA (LINUX)
   :   Add cloud-init user data. HPE Morpheus Enterprise 4.1.0 and earlier assumes bash syntax. HPE Morpheus Enterprise 4.1.1 and later supports all User Data formats. Refer to <https://cloudinit.readthedocs.io/en/latest/topics/format.html> for more information.
6. Select NEXT
7. Review and then Select COMPLETE

## Adding Spaces

### About this task

Cloud Foundry Spaces are referred to as Resource Pools in Morpheus. You can add a new Space by:

### Procedure

1. Navigating to the Cloud and selecting the Resources tab.
2. Then, click :guilabel:‘+ Add Resource’.
3. Give the Resource a Name
4. Expand the Managers, Developers, and Auditors section to add specific Cloud Foundry users to the roles. When adding a user to these sections, use their Cloud Foundry email addresses.

## Provisioning

HPE Morpheus Enterprise automatically seeds MySQL, Redis and RabbitMQ PCF Instance Types, as well as a generic Cloud Foundry Instance Type that will create a shell app used in conjunction with deployments. PCF Marketplace items can also be added to the Provisioning Library in the Cloud detail view Marketplace tab. The Marketplace item will be added to the selected Instance Type and available when selecting the Cloud Foundry Cloud during Instance or App Template creation.

## Deployments

The Cloud Foundry App Instance Type is used in conjunction with deployments. Users do not have to pick deployment when creating a Cloud Foundry App Instance Type, but then Instance will only be a shell of a Cloud Foundry Application.

A deployment in Morpheus can either point to a git hub repository or contain the actual manifest.yml and associated artifacts required for a Cloud Foundry deployment. During the deployment, Morpheus will gather up the files required. Therefore, if the deployment points to a git hub repository, Morpheus will fetch the files from git hub. Once the files are obtained, Morpheus will deploy the artifacts in a similar fashion to the Cloud Foundry cli. This includes parsing the manifest to obtain the parameters to create or update the Cloud Foundry application. Morpheus will ignore certain fields such as memory and disk size because they are dictated by the selected plan. Other fields are utilized such as routes. After parsing the manifest.yml file (including overwriting certain fields), Morpheus is ready to update or create the App in Cloud Foundry.

After the App is configured, the artifacts references in the Morpheus deployment are uploaded to Cloud Foundry for the App. Note that when paths are referenced in the manifest.yml file, the paths continue to be relative to the manifest. So, a jar file under build/libs would need to be found under the build/libs directory.

If Cloud Foundry services are specified in the manifest, they must already exist within Cloud Foundry. Morpheus App templates can be utilized to wire up Cloud Foundry services created by Morpheus. In this case, Morpheus will add all of the included service names defined in the App template to the manifest.yml services section. Therefore, multiple services can be used and wired up by Morpheus.”

## Example

To better understand how Morpheus parses the manifest.yml file, lets take a closer look at the Cloud Foundry ‘spring-music’ project. The project can be found here (<https://github.com/cloudfoundry-samples/spring-music>).

The project contains the required manifest.yml file as well as the source code and build.gradle file to define how the project is to be built. After downloading the project to your local machine, build the project to generate the jar.

Now, let’s take a look at the manifest.yml file:

```
```
---  
applications:  
- name: spring-music  
  memory: 1G  
  random-route: true  
  path: build/libs/spring-music.jar
```
```

Using the Cloud Foundry docs (<https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html>), we can gain a better understanding of how this file is utilized by Cloud Foundry.

- The `-name` parameter defines the name that will be given to the application in Cloud Foundry. Morpheus will overwrite this value with the name given to the Instance being created in Morpheus.
- The `-memory` parameter (as well as the disk\_quota parameter if specified) will be overwritten by Morpheus based on the plan specified for the Instance.
- The `-path` parameter defines, where relative to the manifest.yml file, your Cloud Foundry application can be found.
- The `-random-route parameter`, as well as all other parameters described in the Cloud Foundry documentation will simply be passed through to Cloud Foundry.

## Adding Marketplace Items

### Procedure

1. Navigate to Infrastructure  >  Clouds and select your Cloud Foundry Cloud
2. Select the MARKETPLACE tab
3. Select + ADD MARKETPLACE ITEM
4. Select the HPE Morpheus Enterprise Instance Type to add the Marketplace Item to.
5. Enter version
6. Search for and select Marketplace Item
7. Select SAVE CHANGES

### Results

A Node Type and layout will be created in the Library section and the layout will be automatically added to the Instance Type selected when adding the Marketplace Item.

## Provisioning Instances

### Seeded and Marketplace Items

#### About this task

HPE Morpheus Enterprise automatically seeds MySQL, Redis and RabbitMQ PCF Instance Types, and PCF Marketplace items can also be easily added to the Provisioning Library in the Cloud detail view Marketplace tab. The Marketplace item will be added to the selected Instance Type and available when selecting the Cloud Foundry Cloud during Instance or App Template creation.

#### Procedure

1. Navigate to Provisioning > Instances and select an Instance Type with a Cloud Foundry layout (MySQL, Redis and RabbitMQ plus Marketplace additions)
2. Select NEXT
3. Select a Group and PCF Cloud
4. Add an Instance Name
5. Optionally select and Environment Tag and/or add a custom Tag
6. Select NEXT
7. Select Version and Instance Configuration for a Cloud Foundry layout, ex: Cloud Foundry MySQL
8. Select a Plan and available options for the Plan, or use the custom Plan
9. Select a Space to add the Instance to
10. Optionally configure advanced options
11. Select NEXT
12. Optionally configure Automation options
13. Select NEXT
14. Select COMPLETE

#### Results

NOTE

Compute, Memory, and CPU stats will be pulled, and a Cloud Foundry monitoring health check will be automatically configured for the instance.

### Cloud Foundry App Instance Type

#### About this task

IMPORTANT

Add Deployments in Provisioning > Code > Deployments to be used when provisioning a Cloud Foundry App Instance Type.

NOTE

Minimal options are outlined below.

#### Procedure

1. Navigate to Provisioning > Instances and select the Cloud Foundry App Instance Type
2. Select NEXT
3. Select a Group and PCF Cloud
4. Add an Instance Name
5. Optionally select and Environment Tag and/or add a custom Tag
6. Select NEXT
7. Select a Plan and available options for the Plan, or use the custom Plan
8. Select a Space to add the Instance to
9. Select NEXT
10. In the Deployments section, select a Deployment and Version to be deployed. These can be git repos or files added in Provisioning > Code > Deployments 

    IMPORTANT

    If services are specified in a git repo manifest, HPE Morpheus Enterprise assumes they are already exist in the PCF cloud with matching names.
11. Select NEXT
12. Select COMPLETE

#### Results

This will quickly create the Cloud Foundry Application, and then the deployment will follow which may take longer depending on the app configuration. The location will be updated with the route once it is configured.

NOTE

Compute, Memory, and CPU stats will be pulled, and a Cloud Foundry monitoring health check will be automatically configured for the instance.
