How To Migrate Your Kubernetes Application From On-Premise To Cloud In 8 Steps

Dawood Munavar Feb 26 - 4 min read

Audio : Listen to This Blog.

Introduction

Common customer scenario in the field today is having stateful set applications like MongoDB spun off in Kubernetes cluster with on-prem storage backend.

Porting the containers and Kubernetes across on-premises to cloud environment makes them an ideal choice for organizations that want to achieve true independence from infrastructure providers and spin up development, test or production environments wherever they see fit.

Use-cases

Migration means moving your infrastructure, data from the on-premise data center to the cloud. In this case, Migrating the database applications like MongoDB spun off in Kubernetes cluster from On-prem to Amazon AWS.

Here are the following use-cases of cloud migration,

  • High Availability with Cloud Volumes.
  • Prepare for future needs.
  • Cost Optimization.
  • Disaster Recovery.
  • Data Protection.

Detailed Synopsis

  • Created a 3-node K8s cluster using Kontena Pharos deployed on ESXi VMs, with Guest Operating system as CentOS-7.
  • Cluster contains 1 master, 2 worker nodes.
  • Deployed Statefulset (MongoDB) on k8s cluster & used Ceph-Block Storage as pvc to the cluster.
  • Used Kontena Backup to backup cluster resources and persistent volumes from On-prem to AWS S3.
  • Deploy a 3-node K8s cluster using Kontena Pharos on EC2 instances, with Operating system as CentOS-7.
  • Restore k8s cluster resources & and persistent volumes from kontena backup on EC2 k8s nodes.
  • When the snapshot diff is negligible, we bring down the on-prem application & Perform the following actions
  • Find the names of the restored cluster & persistence volumes in the cloud.
  • Start Mongodb application and run workloads on Databases from the cloud.
  • This way the application is completely migrated from on-prem to cloud.

 

Implementation

	
Step1: Deployed 3 ESXi VMs with CentOS Linux release 7.4.1708

[[email protected] ~]# cat /etc/hosts
10.20.178.11  kube1
10.20.178.12  kube2
10.20.178.14  kube3

Step2: Created 3-node K8s cluster using Kontena Pharos with one master & 2 worker nodes

[[email protected] ~]# kubectl get nodes
NAME    STATUS   ROLES    AGE    VERSION
kube1   Ready    master   2d5h   v1.13.7
kube2   Ready    worker   2d5h   v1.13.7
kube3   Ready    worker   2d5h   v1.13.7

Step3: Added Ceph-block as the default storage class to the k8s cluster

[[email protected] ~]# kubectl get sc
NAME                             PROVISIONER     AGE
kontena-storage-block (default)     ceph.rook.io/block    2d5h
kontena-storage-fs               ceph.com/cephfs      2d5h


Step4: Created a Statefulset (MongoDB) on k8s cluster & used Ceph-Block Storage as pvc to the cluster

[[email protected] ~]# kubectl get pods
NAME                                      READY   STATUS    RESTARTS   AGE
pondering-whale-mongodb-cb8c5b5c7-4rrgb   1/1     Running   0          2d4h

[[email protected] ~]# kubectl get pvc
NAME                      STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS            AGE
pondering-whale-mongodb   Bound    pvc-4bde8b6e-a097-11e9-8b39-005056acbdc4   8Gi        RWO            kontena-storage-block   2d4h


Step5: Used Kontena Backup - a simple tools to backup cluster resources and persistent volumes. Backup to AWS S3 cloud.

ark backup create my-backup --include-namespaces my-namespace

To see details and status of a backup use

ark backup describe my-backup

Step6:Deployed 3 AWS EC2 instances with CentOS Linux release 7 & Created 3-node K8s cluster using Kontena Pharos with one master & 2 worker nodes

[[email protected] ~]$ kubectl get nodes
NAME               STATUS   ROLES    AGE     VERSION
ip-172-31-24-209   Ready    worker   5h51m   v1.13.7
ip-172-31-25-90    Ready    master   5h51m   v1.13.7
ip-172-31-28-9     Ready    worker   5h51m   v1.13.7

Step7: On EC2 instances on AWS cloud, used Kontena Backup - a simple tools to restore cluster resources and persistent volumes

To see the list of existing backups use

ark backup get

Once you've identified which backup you want to restore, use:

ark restore create --from-backup my-backup

Step8: Verification of cluster resources, PODs & persistent volumes on AWS EC2 k8s cluster

[[email protected] ~]$ kubectl get pods
NAME                                      READY   STATUS    RESTARTS   AGE
pondering-whale-mongodb-cb8c5b5c7-4rrgb   1/1     Running   0          4h46m

[[email protected] ~]$ kubectl get pvc
NAME                      STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS            AGE
pondering-whale-mongodb   Bound    pvc-5ada744f-a22d-11e9-8c26-023bf3b043ca   8Gi        RWO            kontena-storage-block   4h46m


“Note”: Kontena backup is not supported on AWS EKS.

 

Conclusion

We provide customers with the following variety of benefits migrating on-prem to AWS,

  • Flexibility.
  • Efficiency.
  • Business Agility.
  • Operational Costs.
  • Work-Force Productivity.

Using Kontena Pharos, MongoDB applications with Gigabytes of data were migrated successfully from On-prem to AWS. More importantly, the application migration happened with no interruptions in service.

 

Leave a Reply