Page
Plan and transform your application
Prerequisites:
- Access to the Developer Sandbox for Red Hat OpenShift
- This example uses data from the move2kube-demos repository on GitHub.
Plan your transformation
Next, we will create a plan to transform your application to run on Kubernetes. During the plan phase, Move2Kube will combine the runtime metadata (if available) with source artifacts and come up with a plan for us.
Here, we provide the path to the Cloud Foundry application’s source directory to Move2Kube using the -s
flag:
$ move2kube plan -s cloud-foundry
INFO[0000] Configuration loading done
INFO[0000] Planning Transformation - Base Directory
INFO[0000] [CloudFoundry] Planning transformation
INFO[0000] Identified 1 named services and 0 to-be-named services
INFO[0000] [CloudFoundry] Done
INFO[0000] [ComposeAnalyser] Planning transformation
INFO[0000] [ComposeAnalyser] Done
INFO[0000] [DockerfileDetector] Planning transformation
INFO[0000] [DockerfileDetector] Done
INFO[0000] [Base Directory] Identified 1 named services and 0 to-be-named services
INFO[0000] Transformation planning - Base Directory done
INFO[0000] Planning Transformation - Directory Walk
INFO[0000] Identified 1 named services and 0 to-be-named services in cfnodejsapp
INFO[0000] Transformation planning - Directory Walk done
INFO[0000] [Directory Walk] Identified 1 named services and 0 to-be-named services
INFO[0000] [Named Services] Identified 1 named services
INFO[0000] No of services identified : 1
INFO[0000] Plan can be found at [/Users/username/m2k.plan].
This creates an m2k.plan
, which is essentially a YAML file. Let's see what's inside the plan file:
$ cat m2k.plan
# click to see the full plan yaml
apiVersion: move2kube.konveyor.io/v1alpha1
kind: Plan
....
In the plan, you can see that Move2Kube has detected the cfnodejsapp
service—the name of our sample Cloud Foundry application—from its manifest.yml
.
The plan file tells us that we can transform the application using two transformers, CloudFoundry or Nodejs-Dockerfile.
The transformer can combine the source artifacts manifest.yml
with the runtime information from cfapps.yaml
to execute the transformation.
Transform your application
Let's invoke move2kube transform on this plan:
$ move2kube transform
INFO[0000] Detected a plan file at path /Users/username/m2k.plan. Will transform using this plan.
INFO[0000] Starting Plan Transformation
? Select all transformer types that you are interested in:
ID: move2kube.transformers.types
Hints:
[Services that don't support any of the transformer types you are interested in will be ignored.]
[Use arrows to move, space to select, <right> to all, <left> to none, type to filter]
> [✓] Buildconfig
[✓] CloudFoundry
[✓] ClusterSelector
[✓] ComposeAnalyser
[✓] ComposeGenerator
[✓] ContainerImagesPushScriptGenerator
[✓] DockerfileDetector
[✓] DockerfileParser
[✓] DotNetCore-Dockerfile
[✓] EarAnalyser
[✓] EarRouter
[✓] Golang-Dockerfile
[✓] Gradle
[✓] Jar
[✓] Jboss
[✓] Knative
[✓] Kubernetes
[✓] KubernetesVersionChanger
[✓] Liberty
[✓] Maven
[✓] Nodejs-Dockerfile
[✓] PHP-Dockerfile
[✓] Parameterizer
[✓] Python-Dockerfile
[✓] ReadMeGenerator
[✓] Ruby-Dockerfile
[✓] Rust-Dockerfile
[✓] Tekton
[✓] Tomcat
[✓] WarAnalyser
[✓] WarRouter
[✓] WinConsoleApp-Dockerfile
[✓] WinSLWebApp-Dockerfile
[✓] WinWebApp-Dockerfile
[✓] ZuulAnalyser
Let's go ahead with the default selection by pressing Return or Enter:
Buildconfig, CloudFoundry, ClusterSelector, ComposeAnalyser, ComposeGenerator, ContainerImagesPushScriptGenerator, DockerfileDetector, DockerfileImageBuildScript, DockerfileParser, DotNetCore-Dockerfile, EarAnalyser, EarRouter, Golang-Dockerfile, Gradle, Jar, Jboss, Knative, Kubernetes, KubernetesVersionChanger, Liberty, Maven, Nodejs-Dockerfile, PHP-Dockerfile, Parameterizer, Python-Dockerfile, ReadMeGenerator, Ruby-Dockerfile, Rust-Dockerfile, Tekton, Tomcat, WarAnalyser, WarRouter, WinConsoleApp-Dockerfile, WinSLWebApp-Dockerfile, WinWebApp-Dockerfile, ZuulAnalyser
? Select all services that are needed:
ID: move2kube.services.[].enable
Hints:
[The services unselected here will be ignored.]
[Use arrows to move, space to select, <right> to all, <left> to none, type to filter]
> [✓] cfnodejsapp
Here, we go ahead with the cfnodejsapp
service:
cfnodejsapp
INFO[0555] Iteration 1
INFO[0555] Iteration 2 - 1 artifacts to process
INFO[0555] Transformer CloudFoundry processing 1 artifacts
INFO[0555] Transformer CloudFoundry Done
INFO[0555] Created 0 pathMappings and 1 artifacts. Total Path Mappings : 0. Total Artifacts : 1.
INFO[0555] Iteration 3 - 1 artifacts to process
INFO[0555] Transformer Nodejs-Dockerfile processing 1 artifacts
? Select port to be exposed for the service cfnodejsapp :
ID: move2kube.services.cfnodejsapp.port
Hints:
[Select Other if you want to expose the service cfnodejsapp to some other port]
[Use arrows to move, type to filter]
> 8080
Other (specify custom option)
Select the port on which you want to expose the cfnodejsapp
service:
8080
INFO[0675] Transformer Nodejs-Dockerfile Done
INFO[0675] Created 2 pathMappings and 2 artifacts. Total Path Mappings : 2. Total Artifacts : 2.
INFO[0675] Iteration 4 - 2 artifacts to process
INFO[0675] Transformer DockerfileImageBuildScript processing 2 artifacts
? Select the container runtime to use :
ID: move2kube.containerruntime
Hints:
[The container runtime selected will be used in the scripts]
[Use arrows to move, type to filter]
> docker
podman
Select the container runtime you want to use:
docker
INFO[0744] Transformer DockerfileImageBuildScript Done
INFO[0744] Transformer DockerfileParser processing 1 artifacts
INFO[0744] Transformer ZuulAnalyser processing 2 artifacts
INFO[0744] Transformer ZuulAnalyser Done
INFO[0744] Transformer DockerfileParser Done
INFO[0744] Created 1 pathMappings and 4 artifacts. Total Path Mappings : 3. Total Artifacts : 4.
INFO[0744] Iteration 5 - 4 artifacts to process
INFO[0744] Transformer ClusterSelector processing 2 artifacts
? Choose the cluster type:
ID: move2kube.target.clustertype
Hints:
[Choose the cluster type you would like to target]
[Use arrows to move, type to filter]
> Openshift
AWS-EKS
Azure-AKS
GCP-GKE
IBM-IKS
IBM-Openshift
Kubernetes
Now you need to select the cluster type you want to deploy to. Select the Openshift cluster type:
Openshift
INFO[0842] Transformer ClusterSelector Done
INFO[0842] Transformer Buildconfig processing 2 artifacts
? What kind of service/ingress to create for cfnodejsapp's 8080 port?
ID: move2kube.services."cfnodejsapp"."8080".servicetype
Hints:
[Choose Ingress if you want a ingress/route resource to be created]
[Use arrows to move, type to filter]
Ingress
LoadBalancer
NodePort
> ClusterIP
Don't create service
Select the ClusterIP
to create a service in the OpenShift cluster:
ClusterIP
? Provide the minimum number of replicas each service should have
ID: move2kube.minreplicas
Hints:
[If the value is 0 pods won't be started by default]
Let's go ahead with the default option again—2 replicas for each service:
2
? Enter the URL of the image registry :
Hints:
[You can always change it later by changing the yamls.]
[Use arrows to move, type to filter]
Other (specify custom option)
index.docker.io
> quay.io
us.icr.io
Then you need to select the registry where your images are hosted. Here, we’ve selected quay.io
. Select Other if your registry name is not listed.
quay.io
? Enter the namespace where the new images should be pushed :
ID: move2kube.target.imageregistry.namespace
Hints:
[Ex : myproject]
(myproject) username
Input the username or organization that you want to push an image to. For example, if you enter danieloh30 as the username, the image path will be quay.io/danieloh30/cfnodejsapp
.
danieloh30
? [quay.io] What type of container registry login do you want to use?
ID: move2kube.target.imageregistry.logintype
Hints:
[Docker login from config mode, will use the default config from your local machine.]
[Use arrows to move, type to filter]
Use existing pull secret
> No authentication
UserName/Password
Select No authentication for the container registry login type:
No authentication
INFO[2439] Generating Buildconfig pipeline for CI/CD
INFO[2439] Generating Buildconfig pipeline for CI/CD
INFO[2439] Transformer Buildconfig Done
INFO[2439] Transformer ComposeGenerator processing 2 artifacts
INFO[2439] Transformer ComposeGenerator Done
INFO[2439] Transformer ContainerImagesPushScriptGenerator processing 2 artifacts
INFO[2439] Transformer ContainerImagesPushScriptGenerator Done
INFO[2439] Transformer ClusterSelector processing 2 artifacts
INFO[2439] Transformer ClusterSelector Done
INFO[2439] Transformer Knative processing 2 artifacts
INFO[2439] Transformer Knative Done
INFO[2439] Transformer ClusterSelector processing 2 artifacts
INFO[2439] Transformer ClusterSelector Done
INFO[2439] Transformer Kubernetes processing 2 artifacts
INFO[2439] Transformer Kubernetes Done
INFO[2439] Transformer ClusterSelector processing 2 artifacts
INFO[2439] Transformer ClusterSelector Done
INFO[2439] Transformer Tekton processing 2 artifacts
? Provide the ingress host domain
ID: move2kube.target.ingress.host
Hints:
[Ingress host domain is part of service URL]
(myproject.com)
It then asks for the Ingress hosting domain. You can get this from the cluster you are going to deploy to; however, you don't need to use Ingress because the Red Hat OpenShift cluster allows you to create a Route to access the application based on the fully qualified domain name (FQDN) domain. Go ahead with the default response by pressing the Return or Enter key.
ID: move2kube.target.ingress.host
Hints:
[Ingress host domain is part of service URL]
myproject.com
INFO[2780] Transformer Tekton Done
INFO[2780] Created 35 pathMappings and 9 artifacts. Total Path Mappings : 38. Total Artifacts : 8.
INFO[2780] Iteration 6 - 9 artifacts to process
INFO[2780] Transformer Parameterizer processing 5 artifacts
INFO[2780] Transformer Parameterizer Done
INFO[2780] Transformer ReadMeGenerator processing 6 artifacts
INFO[2780] Transformer ReadMeGenerator Done
INFO[2780] Plan Transformation done
INFO[2780] Transformed target artifacts can be found at [/Users/username/myproject].
Finally, the transformation is successful, and the target artifacts should be available inside the ./myproject
directory. To view the structure of the ./myproject
directory, execute the following command:
# click to see the output
$ tree myproject
You should see that all the deployment artifacts are present inside of the ./myproject
directory.