One of the most commonly adopted cloud-migration strategy is to lift and shift applications from on-premise to the cloud. Perhaps a state missing in the below CMM is called “Cloud Washed”, a prevalent industry practice in which legacy apps are re-branded as cloud apps, by just moving them out to the cloud. I would place it at the bottom. In my opinion apps should move to cloud, not just for a better cost optimization but also to exploit the elasticity and get the speed, agility and nimbleness required to release new features to market faster, cheaper and smarter. And that’s what Cloud Native Apps do.
In a brownfield environment, the biggest challenge in adopting modern applications principles is refactoring apps, that is going back to design board, breaking open the app, applying 12 (15) factors, correctly finding bounded contexts and more. Wait, wasn’t the app already in its midlife, and would possibly be sunsetted in couple of years ? So what is the immediate value realised after all this pain ?
What if you could,
find a middle ground ?
benefit from the goodness of a “platform” ?
migrate your legacy app into containers, with no/minimal to moderate dev effort, and better yet, automatically run it on a modern system like Kubernetes ?
forward engineer, from source to production and gradually adopt continuous delivery practices for the app ?
repeat it for more apps with confidence, like in a “migration-factory” ?
This blog shows how Google Cloud’s Migrate for Anthos (M4A) help solve the problem without breaking a sweat. I will demonstrate with absolutely zero changes to the app, and with few clicks how I moved a WordPress app backed by MySQL from a VM running on compute engine to a StatefulSet Pod running on Kubernetes.
Step 1 : Deploy the VM App (Source)
Google Cloud Marketplace is home to numerous open source, paid products and solutions that you could deploy to Google Cloud. Under the hood, the solutions are packaged as Deployment Manager Jinja/Python scripts, GCP’s IaC solution. The MarketPlace also provides easy customization, so you can choose the T-shirt size for the VMs and disks, that best suite your need. But for now let’s just “Click to Deploy”.
Step 2 : Review that app
Step 3 : Configure M4A and Migrate
Step 3.1 : Processing Clusters
Processing cluster is the Target GKE Kubernetes cluster. Create a new one or deploy to an existing cluster.
Step 3.2 : Sources
The source is where the VM App resides.In our case the WordPress VM on GCE. As you will see from the dropdown, M4A supports
VMware, AWS and Azure along with Google Cloud. For other clouds, M4A requires additionally the setup of Migrate for Compute (M4C). I would plan to demonstrate that later, as an addendum or Part-B to this post.
Step 3.3 : Migration
Provide the required details, along with the intent to migrate only the
image, data or both. After creating migration, run the migration.
Step 3.4 : Review generated artifact
This is where things get interesting. The tool automatically creates the necessary artifacts including a Dockerfile for the Container App, a Kubernetes Deployment spec YAML. It also automatically pushes a Base Image, and a container Image (for the app) to Google Container Registry (GCR) within the projects’ repository.
Step 3.5 : Voila ! The app is migrated…
What lies beneath ?
Let’s do an analysis of what just happened, and what did the tool do under the hood ?
4.1 : Review M4A CRDs & Pods
M4A CRDs is deployed to the Target “Processing Cluster”, chosen in the above Step 3.1. The M4A CRDs and Pods can be viewed here.
This is the core M4A infrastructure that helps migrate the app, create disks and generate artefacts such as Dockerfile and K8s Deployment manifest. Let’s review them.
4.2 : Review Pods, Services and StatefulSet
Because there is a MySQL Database backing the WordPress app, the Container app is implemented as a StatefulSet. This is indicated when user chooses
"data" or "image & data" while configuring the migration in Step 3.3. When any of the latter 2 is chosen, the migration tool will create a
PersistentVolume (PV) in Kubernetes and map the GCE Persistent Disk attached to the WordPress VM.
By default there is no Ingress / Service type LoadBalancer deployed as part of the generated manifest, so you will have to expose the Pod WebService using one of the methods.
4.3 : Review PV, PVCs and StorageClass
M4A extracts the
Persistent Disk (Google) associated with the VM or incase of a VMware environment, the
.vmdk disk and stream-migrate it to GCP project hosting the cluster.
4.4 : Dockerfile
# Please refer to the documentation: # https://cloud.google.com/migrate/anthos/docs/dockerfile-reference FROM anthos-migrate.gcr.io/v2k-run-embedded:v1.6.2 as migrate-for-anthos-runtime # Image containing data captured from the source VM FROM gcr.io/reju-anthos-bank/wordpress-multisite-1-vm-non-runnable-base:3-14-2021--12-2-31 as source-content # If you want to update parts of the image, add your commands here. # For example: # RUN apt-get update # RUN apt-get install -y \ # package1=version \ # package2=version \ # package3=version # RUN yum update # RUN wget http://github.com COPY --from=migrate-for-anthos-runtime / / # Migrate for Anthos image includes entrypoint ENTRYPOINT [ "/.v2k.go" ]
Notice that M4A creates a multi-stage build with a base-image that represent the M4A-runtime. The relevant filesystem source is extracted from the VM and it becomes part of the new container image represented by
Forward engineering with CI/CD
In Step 4.4, you can add / replace content of the File system via RUN/ADD/COPY. This provides an extension to not just migrate a running VM environment to a running container, but also help us to make new modifications or patches to the application, which opens up all new possibilities to further enhance the build & deploy pipelines via CI/CD.
Assess, what are good candidate apps for M4A
There are 2 tools for Linux and Windows environment that comes handy to determine if your application is a good candidate for M4A to seamlessly migrate the app. The fit score tells what level of manual effort may be expected pre/post migration. A score of > 7 is a good fit for M4A with moderate to no dev efforts. Like in this example we didn’t require to do any changes at all.
m4a-fit-collect.sh runs the commands like
netstat, hostname, systemctl, service, ps, lsof etc… to determine the state of the VM and the processes that are running and ports to which they write. In addition the relevant files are copied into the tarball for analysis from /etc/* and /proc/* directories. A full list can be found here
Application Portfolio Analysis & Migration Path
Tool supported assessments, both at an app (VM) level like
m4a-fit-collect.sh and at a portfolio level, like Stratozone helps you develop an app migration strategy for the cloud. But broadly put together, an enterprise may have a combinations of some of the below applications, and bucketing them can help identify what applications can be a better fit for M4A. COTS/ISV, J2EE, IIS .NET (migrated to Windows Containers), WebSphere, JBoss, Tomcat, J2EE Apps, Web Apps, Portals & CMS like WordPress, Drupal etc.
We saw how Migrate for Anthos can help significantly speed up the journey of a legacy application to Container on Kubernetes, without even changing a line of code. While this may not necessarily be true for complex application and hence doing a pre-assessment with a fit-score analysis is useful.
It is also not required that all applications must move to cloud. You could modernize on-premise and get the same result using Anthos On Prem.
Thanks for reading !