Chapter 7. Generating platform assets for application deployment
Starting from MTA version 7.3.0, you can use the discover and generate commands in containerless mode to automatically generate the manifests needed to deploy a Cloud Foundry (CF) application in the OpenShift Container Platform:
Use the
discovercommand to generate the discovery manifest in the YAML format directly from a CF instance or from either of the following manifest files:- A single application manifest
- A CF manifest
- A path to the directory with multiple manifest files, for example, with application manifests, CF manifests, or both of these manifest types.
The discovery manifest preserves the specifications found in the CF manifest. The specifications define the metadata, runtime, and platform configurations.
-
Use the
generatecommand to generate the deployment manifest for OCP deployments by using the discovery manifest. The deployment manifest is generated by using a templating engine, such as Helm, that converts the discovery manifest into a Kubernetes-native format. You can also use this command to generate non-Kubernetes manifests, such as a Dockerfile or a configuration file.
Generating platform assets for application deployment is a Developer Preview feature only. Developer Preview features are not supported by Red Hat in any way and are not functionally complete or production-ready. Do not use Developer Preview features for production or business-critical workloads. Developer Preview features provide early access to upcoming product features in advance of their possible inclusion in a Red Hat product offering, enabling customers to test functionality and provide feedback during the development process. These features might not have any documentation, are subject to change or removal at any time, and testing is limited. Red Hat might provide ways to submit feedback on Developer Preview features without an associated SLA.
Benefits of generating deployment assets
Generating deployment assets has the following benefits:
- Generating the Kubernetes and non-Kubernetes deployment manifests.
- Generating deployment manifests by using familiar template engines, for example, Helm, that are widely used for Kubernetes deployments.
- Adhering to Kubernetes best practices when preparing the deployment manifest by using Helm templates.
7.1. Generating a discovery manifest Copy linkLink copied to clipboard!
You can generate the discovery manifest for the Cloud Foundry (CF) application by using the discover command. The discovery manifest preserves configurations, such as application properties, resource allocations, environment variables, and service bindings found in the CF manifest.
Prerequisites
- You have Cloud Foundry (v3) as a source platform.
- You installed MTA CLI version 7.3.0 or later.
Procedure
-
Open the terminal application and navigate to the
<MTA_HOME>/directory. List the supported platforms for the discovery process:
mta-cli discover --list-platforms
$ mta-cli discover --list-platformsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Generate the discovery manifest:
mta-cli discover cloud-foundry --input <path_to_input> --output-dir <path_to_output-directory>
$ mta-cli discover cloud-foundry --input <path_to_input> --output-dir <path_to_output-directory>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.2. Performing a live discovery in a remote CF instance Copy linkLink copied to clipboard!
You can use a live discovery if you want to determine what is deployed in a certain Cloud Foundry (CF) cluster. For example, you can determine how many applications are in the cluster. You can also use the live discovery if you do not have access to manifest YAML files.
You can run the live discovery for a remote CF instance by using the mta-cli discover cloud-foundry --use-live-connection --spaces=<space_name> command.
You must always define Cloud Foundry spaces to analyze during a live discovery by using the --spaces option.
Prerequisites
- You have permission to remotely connect to the CF instance.
Procedure
Optional: Investigate the contents of the remote CF instance
cf spaces cf apps
$ cf spaces $ cf appsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the CF configuration file to the directory of your choice:
mkdir <path_to_the_directory>/.cf
$ mkdir <path_to_the_directory>/.cfCopy to Clipboard Copied! Toggle word wrap Toggle overflow Run the live discovery in a remote CF instance:
mta-cli discover cloud-foundry --use-live-connection --spaces=<space_name> --output-dir <path_to_output_directory> --cf-config=<path_to_CF_config_file>
$ mta-cli discover cloud-foundry --use-live-connection --spaces=<space_name> --output-dir <path_to_output_directory> --cf-config=<path_to_CF_config_file>Copy to Clipboard Copied! Toggle word wrap Toggle overflow The command runs the discovery for each application from each space.
If you want to run the discovery for a specific application, enter, for example:
mta-cli discover cloud-foundry --use-live-connection --app-name=<application_name> --spaces=<space_name> --output-dir <path_to_output_directory> --cf-config=<path_to_CF_config_file>
$ mta-cli discover cloud-foundry --use-live-connection --app-name=<application_name> --spaces=<space_name> --output-dir <path_to_output_directory> --cf-config=<path_to_CF_config_file>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.3. Concealing sensitive information in a discovery manifest Copy linkLink copied to clipboard!
You can conceal sensitive information, for example, services and docker credentials, in a Cloud Foundry (CF) discovery manifest by using the mta-cli discover cloud-foundry --conceal-sensitive-data command. This command generates the following files:
- A discovery manifest
- A file with concealed data
If you do not specify the --conceal-sensitive-data option, the option is automatically set to false.
Procedure
Display the contents of the CF manifest and locate sensitive data:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Generate the discovery manifest for the CF application as an output file and conceal sensitive data:
mta-cli discover cloud-foundry --conceal-sensitive-data=true --input <path_to_application_manifest> --output-dir <path_to_output_directory>
$ mta-cli discover cloud-foundry --conceal-sensitive-data=true --input <path_to_application_manifest> --output-dir <path_to_output_directory>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Display the repository structure:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Display the contents of the discovery manifest:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The sensitive data was replaced with a UUID (Universally Unique Identifier).
Display the contents of the
secrets_<discovery_manifest_name>.yamlfile:cat secrets_<discovery_manifest_name>.yaml f0e9ea9e-1913-446f-8483-da9301373eef: docker-registry-user
$ cat secrets_<discovery_manifest_name>.yaml f0e9ea9e-1913-446f-8483-da9301373eef: docker-registry-userCopy to Clipboard Copied! Toggle word wrap Toggle overflow The file contains the mapping of the UUID to the concealed sensitive data.
7.4. Generating a deployment manifest Copy linkLink copied to clipboard!
You can auto-generate the Red Hat OpenShift Container Platform deployment manifest for the Cloud Foundry (CF) application by using the generate command. Based on the Helm template that you provide, the command generates manifests, such as a ConfigMap, and non-Kubernetes manifests, such as a Dockerfile, for application deployment.
Prerequisites
- You have Cloud Foundry (v3) as a source platform.
- You have OpenShift Container Platform as a target platform.
- You installed MTA CLI version 7.3.0.
- You generated a discovery manifest.
- You created a Helm template with the required configuration for the OCP deployment.
Procedure
-
Open the terminal application and navigate to the
<MTA_HOME>/directory. Generate the deployment manifest as an output file:
mta-cli generate helm --chart-dir helm_sample \ --input <path_to_discovery-manifest> \ --output-dir <location_of_deployment_manifest> \
$ mta-cli generate helm --chart-dir helm_sample \ --input <path_to_discovery-manifest> \ --output-dir <location_of_deployment_manifest> \Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the ConfigMap:
mta-cli cd <location_of_deployment_manifest> \ $ cat configmap.yaml cat configmap.yaml cat Dockerfile
$ mta-cli cd <location_of_deployment_manifest> \ $ cat configmap.yaml $ cat DockerfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the Dockerfile:
mta-cli cd <location_of_deployment_manifest> \ $ cat Dockerfile cat Dockerfile
$ mta-cli cd <location_of_deployment_manifest> \ $ cat DockerfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow
7.5. The discover and generate command options Copy linkLink copied to clipboard!
You can use the following options together with the discover or generate command to adjust the command behavior to your needs.
| Command | Option | Description |
|---|---|---|
|
|
| An application to run the discovery for. |
|
| Display details for different command arguments. | |
|
| List the available applications on the source platform, for example: | |
|
| List the supported platforms for the discovery process. | |
|
|
Set the log level, for example, | |
|
| Discover Cloud Foundry applications. | |
|
| Extract sensitive information from a discovery manifest and put it into a separate file. | |
|
| Specify the location of the YAML manifest file to discover the CF applications, for example:
| |
|
| Specify the location to save the <discovery-manifest-name>.yaml file. | |
|
| A comma-separated list of Cloud Foundry spaces to analyze during a live discovery, for example: --spaces=space1,space2,…
| |
|
| Enable real-time discovery by using live platform connections. | |
|
|
| Display details for different command arguments. |
|
| Generate a deployment manifest by using the Helm template. | |
|
| Specify a directory that contains the Helm chart. | |
|
| Specify a location of the <discovery-manifest-name>.yaml file to generate the deployment manifest. | |
|
| Generate only non-Kubernetes templates, such as a Dockerfile. | |
|
| Specify a location to which the deployment manifests are saved. | |
|
| Override values of attributes in the discovery manifest with the key-value pair entered from the CLI. |
7.6. Assets generation example Copy linkLink copied to clipboard!
The following is an example of generating discovery and deployment manifests of a Cloud Foundry (CF) Node.js application.
For this example, the following files and directories are used:
-
CF Node.js application manifest name:
cf-nodejs-app.yaml -
Discovery manifest name:
discover.yaml -
Location of the application Helm chart:
helm_sample - Deployment manifests: a ConfigMap and a Dockerfile
-
Output location of the deployment manifests:
newDir
Assumed that the cf-nodejs-app.yaml is located in the same directory as the MTA CLI binary. If the CF application manifest location is different, you can also enter the location path to the manifest as the input.
Prerequisites
- You installed MTA CLI 7.3.0.
- You have a CF application manifest as a YAML file.
- You created a Helm template with the required configurations for the OCP deployment.
Procedure
-
Open the terminal application and navigate to the
<MTA_HOME>/directory. Verify the content of the CF Node.js application manifest:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Generate the discovery manifest:
mta-cli discover cloud-foundry \ --input cf-nodejs-app.yaml \ --output discover.yaml \
$ mta-cli discover cloud-foundry \ --input cf-nodejs-app.yaml \ --output discover.yaml \Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the content of the discover manifest:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Generate the deployment manifest in the
newDirdirectory by using thediscover.yamlfile:mta-cli generate helm \ --chart-dir helm_sample \ --input discover.yaml --output-dir newDir
$ mta-cli generate helm \ --chart-dir helm_sample \ --input discover.yaml --output-dir newDirCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check the contents of the Dockerfile in the
newDirdirectory:cat ./newDir/Dockerfile FROM busybox:latest RUN echo "Hello cf-nodejs!"
$ cat ./newDir/Dockerfile FROM busybox:latest RUN echo "Hello cf-nodejs!"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check the contents of the ConfigMap in the
newDirdirectory:Copy to Clipboard Copied! Toggle word wrap Toggle overflow In the ConfigMap, override the
nametonodejs-appandINSTANCESto2:mta-cli generate helm \ --chart-dir helm_sample \ --input discover.yaml --set name="nodejs-app" \ --set instances=2 \ --output-dir newDir \
$ mta-cli generate helm \ --chart-dir helm_sample \ --input discover.yaml --set name="nodejs-app" \ --set instances=2 \ --output-dir newDir \Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check the contents of the ConfigMap again:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow