Containerize a Monolith Application Running on VM using “Application Transformer for VMware Tanzu” in Just Few Clicks

Application Transformer for VMware Tanzu can help you to containerize VM based application running on a vSphere Environment. In this post, I will explain step by step about containerizing a Java based application running on virtual machine.

I am assuming that the Application Transformer for VMware Tanzu is already deployed and up&running. In case you need to know about installation, You can refer my previous blog: https://mappslearning.wordpress.com/2021/09/09/application-transformer-for-vmware-tanzu-on-vmc-on-aws/

Let’s get started.

Pre-requirements

– Application Transformer for VMware Tanzu is up and Running. Validate the access by logging in.

– Java based application is deployed on a Tomcat server running on VM (If you need help, refer my earlier blog, link mentioned above)

– VCenter Administrative Access

– Username and Password of VM where application is deployed

Containerization Process

– Login to the Application Transformer for VMware Tanzu. Hit the https://172.168.16.7/login url. Replace a correct IP Address.

– Once you login, You will see below landing page.

– There are two tiles here, one about discovery aspect and another is about Analysis. I have explained about them in earlier blog post and you can see the link above. Let’s Click on the Discovery Tab above.

– Once you Click on Discovery, You will see the following page.

– What you can see here is, the VCenter is already added. Before we can containerize an application, We need to discover the Virtual Machine.

Note: Another point to highlight is, In this demonstration, vRNI is not connected and its needed when your application is deployed across multiple VM’s. In this case, I will be demonstrating on one VM and hence i have not added vRNI.

Virtual Machine Scan

We need to discover the Virtual Machine before we can containerize an application. Let’s do that.

– Expand the VCenter and Select the right folder where your VM exists. Alternatively, you can scan complete VCenter as well but it will take long time and also depend on number of objects available.

– Select the Folder and click on Scan

– You will be prompted to make selection here. You can select any option but i will select Scan only and will do Introspection later. Basically, Scan will just add the VM in Application Transformer for VMware Tanzu but Introspection will also discover the running softwares on it. Uncheck the “Apply Credential Policy” and Click on “No, Scan Only”.

– Monitor the Task status and wait for success.

– Click on the vCenter Scan Task to see more detail.

Great, Now we are ready for Next Steps.

VM Introspection

– Before we start VM introspection, Let’s do the following that is needed little later.

Creating VM and Registry Credentials

– Click on the Credentials tab

– Click on Add Credential, Fill the detail and Click on Save

– Click on Add Credentials once again to add Docker registry Credential. In this example, I am using DockerHub as docker image registry.

– Now, Lets move forward with Introspection.

Associate Credential with VM

– Click on Virtual Machines Tab and select the VM you want to introspect.

– Following popup will appear, select the credential and Click on Update.

– You can see the Credential is now associated with VM.

– Select VM again and Click on Introspect button. You will see that the introspection will start.

– Monitor the Task and wait for completion.

Now, It’s time to containerize.

Containerize an Application

– Before we start containerization, Lets add the container registry where we will store the container image. In this example, I am using Dockerhub.

– Click on Registry Tab

– Click on ADD Registry Button and fill the detail.

– Click on Test and once connection is successful, Save the details.

– Once saved, you can see the entry in Registry tab.

– Move back to Virtual Machines tab and select the VM you introspected. As tomcat is running on your VM, It will be recognized.

e.g.

Since I have tried couple of times, so you are seeing that it shows containerize, But we can do again.

– Click on Discover Tab to discover the applications. Wait for the Discovery Task to get completed.

– Now, We are ready to containerize the application. Click on Containerize.

Note that, You can select your own Tomcat and JR binaries to use, But in this case, i would just like to go with default and pull from internet. Click on Continue and fill the details.

Click Continue and Finish.

– As soon, you trigger the Task. You will see the build Image task will start.

– After build image is done, you will notice that Push Image Task will start.

– Soon Both task will be finished.

Well, Now our application is containerized. To see the artifacts, Click on the Image Artifacts link.

It will download a zip file, Unzip and you will see the following content.

Cool, So you can see the Deployment manifest, Dockerfile etc here, You can modify the Deployment Manifest and deploy on any Kubernetes Cluster.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: --FIX ME--
  labels:
    app: --FIX ME--
spec:
  replicas: 1
  selector:
    matchLabels:
      app: --FIX ME--
  template:
    metadata:
      labels:
        app: --FIX ME--
    spec:
      containers:
      - name: --FIX ME--
        image: dineshtripathi30/apache:latest
        env:
        - name: JAVA_OPTS
          value: '"-Djava.security.egd=file:///dev/urandom -Djava.awt.headless=true -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027"'

e.g. Here is Modified File.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: tanzuapp
  labels:
    app: tanzuapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: tanzuapp
  template:
    metadata:
      labels:
        app: tanzuapp
    spec:
      containers:
      - name: tanzuapp
        image: dineshtripathi30/apache:latest
        env:
        - name: JAVA_OPTS
          value: '"-Djava.security.egd=file:///dev/urandom -Djava.awt.headless=true -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027"'

Now, You can simply run kubectl command to create this resource and you are done.

Hopefully , you have found this post useful. I will bring more scenarios later.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s