1. Collect

Note: This is an optional step. If you are not familiar with Cloud Foundry or you do not want to collect information from your running app, skip to Customizing the output.

To analyze the running application in Cloud Foundry (CF), the Move2Kube CLI tool provides a command called collect. As the name suggests, the collect command collects information about applications running in the cloud.

  • For collecting information from a CF running instance, you might require cf CLI for logging into Cloud Foundry. If you want to target a specific Kubernetes cluster for your yamls, you will need either oc, and kubectl to collect information about the target cluster.

  • If you are logged into the Cloud Foundry instance, information about the apps such as environment variables, services, and more are collected. If you are logged into Kubernetes clusters, it collects information about the types of resources that are installed on the cluster, such as whether it has Tekton, BuildConfigs, etc.

  • All the information that was collected gets written into a directory called m2k_collect as YAML files. In this case, the info about Cloud Foundry apps is written to a sub-directory called cf. These YAMLs can then be used during the plan phase to get a holistic plan combining the source and metadata.

For example: Some of the information that is collected is port and environment variable information. This allows Move2Kube to select the right ports and set the right environment variables for each service when generating Dockerfiles for containerizing these services.

Collecting info from e2e-demo app

Prerequisites

  1. The cf tool installed and you have logged into your Cloud Foundry instance. Run cf target to check if you are logged in. The output should be similar to this:
$ cf target
API endpoint:   https://api.cf.my.cloud.provider.com
API version:    3.107.0
user:           user@gmail.com
org:            my-org
space:          dev
  1. The enterprise-app app in the Cloud Foundry instance is deployed.
$ cf apps

Getting apps in org my-org / space dev as user@gmail.com...

name          requested state   processes           routes
frontend      started           web:1/1             frontend-1234.my.cloud.provider.com
gateway       started           web:1/1, task:0/0   gateway-5678.my.cloud.provider.com
orders        started           web:1/1, task:0/0   orders-1234.my.cloud.provider.com
...

Procedure

  1. Run move2kube collect to collect information about the app from Cloud Foundry.
$ move2kube collect
INFO[0000] Begin collection                             
INFO[0000] [*collector.ClusterCollector] Begin collection
INFO[0000] [*collector.ClusterCollector] Done           
INFO[0000] [*collector.ImagesCollector] Begin collection
INFO[0000] [*collector.ImagesCollector] Done            
INFO[0000] [*collector.CfAppsCollector] Begin collection
INFO[0011] [*collector.CfAppsCollector] Done            
INFO[0011] [*collector.CfServicesCollector] Begin collection
INFO[0026] [*collector.CfServicesCollector] Done        
INFO[0026] Collection done                              
INFO[0026] Collect Output in [/Users/user/Desktop/tutorial/m2k_collect]. Copy this directory into the source directory to be used for planning.

The output will be in a directory called m2k_collect with a sub-directory called cf containing two 2 YAML files: CfApps and CfServices.

$ ls m2k_collect/
cf		clusters	images
$ ls m2k_collect/cf/
cfapps-e3a2f9d68a7a5ecc.yaml		cfservices-32194c9906854947.yaml

The CfApps file contains all the information that was collected about the app such as service names, environment variables, ports, etc. An example is provided here

<details markdown="block">
<summary markdown="block">
# click to see the full yaml
apiVersion: move2kube.konveyor.io/v1alpha1
kind: CfApps
......

The returned YAML.

apiVersion: move2kube.konveyor.io/v1alpha1
kind: CfApps
spec:
  applications:
    - application:
    guid: id1
    createdat: "2021-12-14T10:01:40Z"
    updatedat: "2021-12-14T10:03:08Z"
    name: orders
    memory: 1024
    instances: 1
Click to see the rest of the yaml.

Now that we have collected the runtime information from the app running in our Cloud Foundry instance, we can use it during the planning phase by simply copying it into the source directory before starting the planning. All the steps are same as the Plan step.

Next steps

Next we will customize the output that Move2Kube produces using customizations.