Page
Collect your data into a directory
Move2Kube is a tool that helps automate your migration to Kubernetes from platforms like Cloud Foundry or Docker Compose. It analyzes source files, such as manifest files, and generates the deployment artifacts required to deploy the application in Kubernetes.
Prerequisites:
- Access to the Developer Sandbox for Red Hat OpenShift
- This example uses data from the move2kube-demos repository on GitHub.
Move2Kube is a tool that helps automate your migration to Kubernetes from platforms like Cloud Foundry or Docker Compose. It analyzes source files, such as manifest files, and generates the deployment artifacts required to deploy the application in Kubernetes.
To transform a Cloud Foundry application to Kubernetes, simply execute the following command:
$ move2kube transform -s cloud-foundry
Move2Kube will automatically analyze the artifacts in the cloud-foundry
directory and transform and create all artifacts required for deploying the application in Kubernetes.
Create a source code directory
First, you will need a directory that contains the source code files and the manifest.yml
file of a Cloud Foundry application.
In this learning path, we will use the
cloud-foundry
sample directory from the move2kube-demos repository:$ curl https://move2kube.konveyor.io/scripts/download.sh | bash -s -- -d samples/cloud-foundry -r move2kube-demos
Let's see the structure inside the
./cloud-foundry
directory. Thecloud-foundry
directory contains the source code files and themanifest.yml
file:$ tree cloud-foundry cloud-foundry/ ├── cfnodejsapp │ ├── main.js │ ├── manifest.yml │ ├── package-lock.json │ └── package.json └── m2k_collect └── cf └── cfapps.yaml
- Next, install the following tools:
- To verify that dependencies were installed correctly, you can run any of the following commands:
$ move2kube version
$ docker version
$ podman info
$ kubectl version
- Finally, install the Cloud Foundry CLI.
The example application
To demonstrate how to migrate a Cloud Foundry application to Kubernetes with Move2Kube, we will use the source code inside the cloud-foundry/cfnodejsapp directory.
If you want to try out Move2Kube on your Cloud Foundry application, then in place of our sample cloud-foundry directory, provide the path of the source directory (containing the source code and/or manifest files) of your Cloud Foundry application to Move2Kube during the plan phase.
Deploy to Cloud Foundry
Optional step: Here we will deploy a simple Node.js application into Cloud Foundry. If you already have a running Cloud Foundry application, you can use that instead.
- Provision a Cloud Foundry app with the name
cfnodejsapp
using your cloud provider (e.g., IBM Cloud). - Make note of the API endpoint. (You can find a list of supported API endpoints for the IBM Cloud Foundry service in the documentation).
Log in to Cloud Foundry using the following command:
$ cf login -a <YOUR CF API endpoint>
Run the following commands to deploy the sample application to Cloud Foundry. The sample application’s source code is present inside the
./cloud-foundry/cfnodejsapp
folder.$ cf push -f ./cloud-foundry/cfnodejsapp -p ./cloud-foundry/cfnodejsapp
You can visit the URL of the application (you can get this by running cf apps) to see it running.
Generate target artifacts
Now that we have a running Cloud Foundry application, we can transform it using Move2Kube. We will use a three-stage process (collect, plan, and transform) for the transformation. Be sure to run these steps from the directory where the cloud-foundry directory is located.
Collect your data
We will first collect some data about our running Cloud Foundry application.
Note: This step is only necessary if you are interested in metadata such as environment variables from a running instance. If you don't have a running application, you can use the m2k_collect
directory that comes with the sample.
Here we will limit the collection to only Cloud Foundry information using the
-a cf
annotation flag:$ cf login -a <YOUR CF API endpoint> $ move2kube collect -a cf INFO[0000] Begin collection INFO[0000] [*collector.CfAppsCollector] Begin collection INFO[0013] [*collector.CfAppsCollector] Done INFO[0013] [*collector.CfServicesCollector] Begin collection INFO[0027] [*collector.CfServicesCollector] Done INFO[0027] Collection done INFO[0027] Collect Output in [/Users/username/m2k_collect]. Copy this directory into the source directory to be used for planning.
The data we collect will be stored in a new directory called
./m2k_collect
.$ ls m2k_collect cf
- The
./m2k_collect/cf
directory contains a YAML file with runtime information about the application you are transforming. The file contains details about the supported buildpacks, the memory, the number of instances, and the supported ports. If there are environment variables, it collects that information, too. - Move
the ./m2k_collect/cf
directory into the source directory./cloud-foundry
: $ mv m2k_collect cloud-foundry/