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 discover command 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 generate command 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.
Important

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

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

  1. Open the terminal application and navigate to the <MTA_HOME>/ directory.
  2. List the supported platforms for the discovery process:

    $ mta-cli discover --list-platforms
    Copy to Clipboard Toggle word wrap
  3. Generate the discovery manifest:

    $ mta-cli discover cloud-foundry --input <path_to_input> --output-dir <path_to_output-directory>
    Copy to Clipboard Toggle word wrap

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.

Important

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

  1. Optional: Investigate the contents of the remote CF instance

    $ cf spaces
    $ cf apps
    Copy to Clipboard Toggle word wrap
  2. Copy the CF configuration file to the directory of your choice:

    $ mkdir <path_to_the_directory>/.cf
    Copy to Clipboard Toggle word wrap
  3. 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>
    Copy to Clipboard Toggle word wrap

    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>
    Copy to Clipboard Toggle word wrap

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
Note

If you do not specify the --conceal-sensitive-data option, the option is automatically set to false.

Procedure

  1. Display the contents of the CF manifest and locate sensitive data:

    $ cat <manifest_name>.yaml
    name: <manifest_name>
    disk_quota: 512M
    memory: 500M
    timeout: 10
    docker:
     image:myregistry/myapp:latest
     username: docker-registry-user
    Copy to Clipboard Toggle word wrap
  2. 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>
    Copy to Clipboard Toggle word wrap

Verification

  1. Display the repository structure:

    $ tree <path_to_discovery_manifest>
    <path_to_discovery_manifest>
    ├── discover_manifest_<app-name>.yaml
    ├── secrets_<discovery_manifest_name>.yaml
    
    1 directory, 2 files
    Copy to Clipboard Toggle word wrap
  2. Display the contents of the discovery manifest:

    $ cat <discovery_manifest_name>.yaml
    name: <discovery_manifest_name>
    timeout: 10
    docker:
     image:myregistry/myapp:latest
     username: $(f0e9ea9e-1913-446f-8483-da9301373eef)
    disk: 512M
    memory: 500M
    instances: 1
    Copy to Clipboard Toggle word wrap

    The sensitive data was replaced with a UUID (Universally Unique Identifier).

  3. Display the contents of the secrets_<discovery_manifest_name>.yaml file:

    $ cat secrets_<discovery_manifest_name>.yaml
    f0e9ea9e-1913-446f-8483-da9301373eef: docker-registry-user
    Copy to Clipboard Toggle word wrap

    The file contains the mapping of the UUID to the concealed sensitive data.

7.4. Generating a deployment manifest

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

  1. Open the terminal application and navigate to the <MTA_HOME>/ directory.
  2. 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> \
    Copy to Clipboard Toggle word wrap
  3. Verify the ConfigMap:

    $ mta-cli cd <location_of_deployment_manifest> \
    $ cat configmap.yaml
    $ cat Dockerfile
    Copy to Clipboard Toggle word wrap
  4. Verify the Dockerfile:

    $ mta-cli cd <location_of_deployment_manifest> \
    $ cat Dockerfile
    Copy to Clipboard Toggle word wrap

7.5. The discover and generate command options

You can use the following options together with the discover or generate command to adjust the command behavior to your needs.

Expand
Table 7.1. Options for discover and generate commands
CommandOptionDescription

discover

--app-name

An application to run the discovery for.

-h, --help

Display details for different command arguments.

--list-apps

List the available applications on the source platform, for example:

$ mta-cli discover cloud-foundry --use-live-connection --spaces=space,space-2 --cf-config=/home/gloria/ --list-apps
INFO[0000] Cloud Foundry client created successfully
INFO[0000] Analyzing space space_name=space
INFO[0006] Apps discovered count=2
INFO[0006] Analyzing space space_name=space-2
INFO[0007] Apps discovered count=1
Space: space
- nginx
- test-app
Space: space-2
- test-app
Copy to Clipboard Toggle word wrap

--list-platforms

List the supported platforms for the discovery process.

--log-level

Set the log level, for example, discover --log-level 1. The default log level is 4.

discover cloud-foundry

 

Discover Cloud Foundry applications.

--conceal-sensitive-data

Extract sensitive information from a discovery manifest and put it into a separate file.

--input

Specify the location of the YAML manifest file to discover the CF applications, for example:

  • A path to the single application manifest.
  • A path to the Cloud Foundry manifest.
  • A path to the directory with multiple manifest files.

--output

Specify the location to save the <discovery-manifest-name>.yaml file.

--spaces

A comma-separated list of Cloud Foundry spaces to analyze during a live discovery, for example:

--spaces=space1,space2,…
Copy to Clipboard Toggle word wrap

--use-live-connection

Enable real-time discovery by using live platform connections.

generate

-h, --help

Display details for different command arguments.

generate helm

 

Generate a deployment manifest by using the Helm template.

--chart-dir

Specify a directory that contains the Helm chart.

--input

Specify a location of the <discovery-manifest-name>.yaml file to generate the deployment manifest.

--non-k8s-only

Generate only non-Kubernetes templates, such as a Dockerfile.

--output-dir

Specify a location to which the deployment manifests are saved.

--set

Override values of attributes in the discovery manifest with the key-value pair entered from the CLI.

7.6. Assets generation example

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

  1. Open the terminal application and navigate to the <MTA_HOME>/ directory.
  2. Verify the content of the CF Node.js application manifest:

    $ cat cf-nodejs-app.yaml
    name: cf-nodejs
    lifecycle: cnb
    buildpacks:
      - docker://my-registry-a.corp/nodejs
      - docker://my-registry-b.corp/dynatrace
    memory: 512M
    instances: 1
    random-route: true
    Copy to Clipboard Toggle word wrap
  3. Generate the discovery manifest:

    $ mta-cli discover cloud-foundry \ --input cf-nodejs-app.yaml \ --output discover.yaml \
    Copy to Clipboard Toggle word wrap
  4. Verify the content of the discover manifest:

    $ cat discover.yaml
    name: cf-nodejs
    randomRoute: true
    timeout: 60
    buildPacks:
    - docker://my-registry-a.corp/nodejs
    - docker://my-registry-b.corp/dynatrace
    instances: 1
    Copy to Clipboard Toggle word wrap
  5. Generate the deployment manifest in the newDir directory by using the discover.yaml file:

    $ mta-cli generate helm \ --chart-dir helm_sample \ --input discover.yaml --output-dir newDir
    Copy to Clipboard Toggle word wrap
  6. Check the contents of the Dockerfile in the newDir directory:

    $ cat ./newDir/Dockerfile
    FROM busybox:latest
    
    RUN echo "Hello cf-nodejs!"
    Copy to Clipboard Toggle word wrap
  7. Check the contents of the ConfigMap in the newDir directory:

    $ cat ./newDir/configmap.yaml
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: cf-nodejs-config
    data:
      RANDOM_ROUTE: true
      TIMEOUT: "60"
      BUILD_PACKS: |
        - docker://my-registry-a.corp/nodejs
        - docker://my-registry-b.corp/dynatrace
      INSTANCES: "1"
    Copy to Clipboard Toggle word wrap
  8. In the ConfigMap, override the name to nodejs-app and INSTANCES to 2 :

    $ mta-cli generate helm \ --chart-dir helm_sample \ --input discover.yaml --set name="nodejs-app" \ --set instances=2 \ --output-dir newDir \
    Copy to Clipboard Toggle word wrap
  9. Check the contents of the ConfigMap again:

    $ cat ./newDir/configmap.yaml
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: nodejs-app
    data:
      RANDOM_ROUTE: true
      TIMEOUT: "60"
      BUILD_PACKS: |
        - docker://my-registry-a.corp/nodejs
        - docker://my-registry-b.corp/dynatrace
      INSTANCES: "2"
    Copy to Clipboard Toggle word wrap
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat