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
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.
cftool installed and you have logged into your Cloud Foundry instance. Run
cf targetto 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: email@example.com org: my-org space: dev
$ cf apps Getting apps in org my-org / space dev as firstname.lastname@example.org... 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 ...
move2kube collectto collect information about the app from Cloud Foundry.
$ move2kube collect INFO Begin collection INFO [*collector.ClusterCollector] Begin collection INFO [*collector.ClusterCollector] Done INFO [*collector.ImagesCollector] Begin collection INFO [*collector.ImagesCollector] Done INFO [*collector.CfAppsCollector] Begin collection INFO [*collector.CfAppsCollector] Done INFO [*collector.CfServicesCollector] Begin collection INFO [*collector.CfServicesCollector] Done INFO Collection done INFO 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:
$ ls m2k_collect/ cf clusters images $ ls m2k_collect/cf/ cfapps-e3a2f9d68a7a5ecc.yaml cfservices-32194c9906854947.yaml
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
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 we will customize the output that Move2Kube produces using customizations.