TNS
VOXPOP
How has the recent turmoil within the OpenAI offices changed your plans to use GPT in a business process or product in 2024?
Increased uncertainty means we are more likely to evaluate alternative AI chatbots and LLMs.
0%
No change in plans, though we will keep an eye on the situation.
0%
With Sam Altman back in charge, we are more likely to go all-in with GPT and LLMs.
0%
What recent turmoil?
0%
Kubernetes / Storage

Tutorial: Migrate Stateful Kubernetes Workloads with Portworx and Velero

By the end of this tutorial, you will be able to migrate WordPress from one namespace to another.
May 1st, 2020 9:52am by
Featued image for: Tutorial: Migrate Stateful Kubernetes Workloads with Portworx and Velero

In the last part of this tutorial series, we have seen how to take snapshots of Portworx volumes and store them in S3-compatible object storage services like MinIO. We will extend that scenario to migrate stateful workloads across namespaces, clusters, and even cloud providers. By the end of this tutorial, you will be able to migrate WordPress from one namespace to another.

Since this is a continuation of the previous tutorial, it assumes that you followed the steps of installing MinIO and registering it with Portworx before proceeding further (Or start from the beginning: Part 1, Part 2, Part 3, Part 4).

Portworx has a mature, enterprise-grade backup and restore for Kubernetes backup. This guide is an alternate approach to using the backup and migration features of Portworx. This tutorial works with both Portworx Essentials and Portworx Enterprise.

Installing Velero

Velero (formerly Heptio Ark) is a tool to backup and restore Kubernetes cluster resources and persistent volumes. It installs as a CRD in Kubernetes to backup an entire namespace or specific resources that match a specific label.

Follow the instructions from the documentation to download and install Velero.

Valero’s backup can be stored in an Amazon S3 bucket. We will use MinIO instead of Amazon S3. Make sure you add the MinIO secret key and access key credentials to the file credentials-velero located in the current directory. Refer to the Velero documentation for more information on this configuration.

Replace the URLs with your MinIO endpoint.


This results in the creation of the namespace velero and a pod running within that.


We have Velero ready to take the backup of a workload and store it in the MinIO bucket. This was done by adding the AWS plugin along with the pointer to the bucket URL.

Notice that Velero is not aware of Portworx at this point which means it cannot take volume snapshots of PVCs. In the next step, we will point Velero to Portworx to use its volume snapshot feature along with the backup.

Configuring Portworx Provider for Velero

Velero uses a plugin model for backups stored in object storage and volume snapshots of block storage. In this scenario, we are using the AWS plugin for object storage and the Portworx plugin for the volume snapshots.


The above command registers the Portworx plugin with Velero. The next step is to point Velero to the default location for snapshots as configured by Portworx. In the previous tutorial, we registered the credentials for MinIO with Portworx to store the volume snapshots in one of the buckets. Velero will continue to use the same configuration each time the backup is initiated.


We just instructed Velero to use the default remote snapshot configuration of Portworx for volume snapshots.

This integration enables Velero to backup Kubernetes resources such as deployments, services, ingress while delegating the volume snapshot job to Portworx. The same process is followed during the restore process.

Backing up WordPress Application with Velero

We are now ready to initiate the backup with Velero. Run the below command to kick off the job.


Check the status by running the ‘velero backup get’ command.

Once it is done, check the MinIO browser. There would be two buckets — one to store volume snapshots created by Portworx and the other for storing Velero backup for the entire workload.

The two objects corresponding to the MySQL and WordPress PVCs are seen here.

The bucket, wp-backup, is used by Velero to dump the complete backup of Kubernetes objects from the WordPress namespace.

Performing a Restore with Velero

With the backup in place, let’s test the restore process with Velero.

We will first delete the wordpress namespace to remove all associated resources with the application including the PVCs.


Let’s attempt the restore now.


Check the status with the below command:


Velero has restored all the resources to the same namespace, WordPress.


The restore process involved Velero in recreating the Kubernetes objects and Portworx in creating the PVCs from cloud snapshots.

The same workflow can be used to migrate stateful workloads across clusters provided you have identical environments with Portworx and Velero installations.

This article concludes the series on running stateful workloads with Portworx.

Janakiram MSV’s Webinar series, “Machine Intelligence and Modern Infrastructure (MI2)” offers informative and insightful sessions covering cutting-edge technologies. Sign up for the upcoming MI2 webinar at http://mi2.live.

Portworx is a sponsor of The New Stack.

Feature image by Siggy Nowak from Pixabay.

Group Created with Sketch.
TNS owner Insight Partners is an investor in: The New Stack.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.