Kubernetes Migration: How To Move Data Freely Across Clusters

This blog focuses on migrating Kubernetes clusters from one cloud provider to another. We will be migrating our entire data from Google Kubernetes Engine to Azure Kubernetes Service using Velero.

Prerequisite

Setup Velero with Restic Integration

Velero consists of a client installed on your local computer and a server that runs in your Kubernetes cluster, like Helm.

Installing Velero Client

You can find the latest release corresponding to your OS and system and download Velero from there:

Extract the tarball (change the version depending on yours) and move the Velero binary to /usr/local/bin

Create a Bucket for Velero on GCP

Velero needs an object storage bucket where it will store the backup. Create a GCS bucket using:

Create a Service Account for Velero

Install Velero Server on GKE and AKS

Use the — use-restic flag on the Velero install command to install restic integration.

After that, you can see a DaemonSet of restic and deployment of Velero in your Kubernetes cluster.

Restic Components

In addition, there are three more Custom Resource Definitions and their associated controllers to provide restic support.

Restic Repository

PodVolumeBackup

PodVolumeRestore

Backup an application on GKE

For this blog post, we are considering that Kubernetes already has an application that is using persistent volumes. Or you can install WordPress as an example as explained here.

We will perform GKE Persistent disk migration to Azure Persistent Disk using Velero.

Follow the below steps:

2. Annotate the pods with the volume names, you’d like to take the backup of and only those volumes will be backed up:

For example,

3. Take a backup of the entire namespace in which the application is running. You can also specify multiple namespaces or skip this flag to backup all namespaces by default. We are going to backup only one namespace in this blog.

4. Monitor the progress of backup:

Once the backup is complete, you can list it using:

You can also check the backup on GCP Portal under Storage.
Select the bucket you created and you should see a similar directory structure:

Velero GCP bucket

Restore the application to AKS

Follow the below steps to restore the backup:

You can monitor the progress of restore:

You can also check on GCP Portal, a new folder “restores” is created under the bucket.

In some time, you should be able to see that the application namespace is back and WordPress and MySQL pods are running again.

Troubleshooting

For any errors/issues related to Velero, you may find below commands helpful for debugging purposes:

Conclusion

The migration of persistent workloads across Kubernetes clusters on different cloud providers is difficult. This became possible by using restic integration with the Velero backup tool. This tool is still said to be in beta quality as mentioned on the official site. I have performed GKE to AKS migration and it went successfully. You can try other combinations of different cloud providers for migrations.

The only drawback of using Velero to migrate data is if your data is too huge, it may take a while to complete the migration. It took me almost a day to migrate a 350 GB disk from GKE to AKS. But, if your data is comparatively less, this should be an efficient and hassle-free way to migrate it.

Originally published at https://www.velotio.com.

--

--

Velotio Technologies is an outsourced software and product development partner for technology startups & enterprises. #Cloud #DevOps #ML #UI #DataEngineering

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Velotio Technologies

Velotio Technologies is an outsourced software and product development partner for technology startups & enterprises. #Cloud #DevOps #ML #UI #DataEngineering