Cloud Native Application Data Protection Using Kasten K10 and Nutanix Karbon: A Practical Guide

Cloud Native Application Data Protection Using Kasten K10 and Nutanix Karbon: A Practical Guide

Table of Contents

Nutanix publishes information for initiatives that help customers integrate the Nutanix platform with other third-party products. Support for these initiatives is handled via the Nutanix community on a best-effort basis. Where open source products are referenced, support is typically provided via GitHub issues in the referenced repositories.


Introduction

At Nutanix, we continue to see new and current customers take advantage of Karbon to rapidly configure and deploy Kubernetes clusters as they progress in their cloud native journeys.

Karbon, an integrated component of Nutanix AOS, is a solution that enables IT operators to deliver and manage end-to-end, production-ready Kubernetes environments with push-button simplicity, all while preserving a native user experience.

It’s worth highlighting that every Karbon Kubernetes cluster is deployed with Nutanix’s full-featured CSI driver, which natively integrates with Nutanix’s storage solutions, Volumes and Files, to deliver persistent storage for stateful containerized applications. S3-compatible storage is also easy to set up using Nutanix Objects.

Nutanix Objects is a software-defined object storage solution that non-disruptively scales out while lowering overall storage costs. It’s designed with an S3-compatible REST API interface to handle large amounts of unstructured data, all from a single namespace. Objects is an ideal target for Kasten backup export, as it provides long-term retention and archiving, as well as cross-region replication. Objects is deployed and managed as part of the Nutanix Enterprise Cloud Platform, eliminating the need for additional storage silos.

With these essential storage components in place, it then becomes easy to integrate Kasten K10 to manage the protection and the mobility of cloud native applications on Karbon. 

The Kasten K10 by Veeam data management software platform has been purpose-built for Kubernetes.  Kasten K10 runs on your cluster in its own namespace and protects your fleet of kubernetes deployments with multi-cluster support. K10 provides secure multi-tenancy with fine grained role based access control. KastenK10 has 

  • Pre-qualified integrations with leading data sources including Relational and NoSQL data services
  • Support for all major cloud-based managed Kubernetes offerings and all leading on-prem distributions
  • Support for storage via Container-Storage Interface (CSI) as well as direct storage integrations for efficiency

Kasten is now a Nutanix Ready certified Partner.

What we’re going to do 

This blog offers a step-by-step guide on how to configure and use Kasten K10 for data management for cloud native applications running on Karbon Kubernetes clusters. We’re going to 

  1. Verify snapshot capabilities of Karbon 
  2. Run the Kasten K10 preflight check
  3. Install Kasten K10 and a sample application (MySQL)
  4. Test the snapshot and recovery of an application  
  5. Create an external object store with Nutanix Objects
  6. Configure Kasten K10 to use this object store
  7. Export snapshot to this object store and test again recovery  

Karbon Snapshot Capability

Before installing Kasten K10 we’re going to verify Karbon snapshot capabilities because :

  1. Kasten supports snapshotting at the  storage layer providing an efficient method for data protection. 
  2. A snapshot is crash-consistent (the state of each file is captured at the same time)
  3. Snapshots are local, which makes restoring and application quicker

For the purpose of this blog, the default activation of the native Nutanix CSI snapshot feature needs to be verified. To do so, you will need admin access to your cluster, as well as a working kubeconfig/kubectl environment.

Verify the Nutanix CSI Snapshot Resources

Execute the following script who check the cluster and if they are not present and if there is a supported configuration, will install the resources:

#!/usr/bin/bash

DRIVER=$(kubectl get sc -o=jsonpath='{.items[?(@.metadata.annotations.storageclass\.kubernetes\.io\/is-default-class=="true")].provisioner}')
VERSION=$(kubectl -n ntnx-system get deployment nutanix-csi-controller -o jsonpath='{.spec.template.spec.containers[?(@.name=="nutanix-csi-plugin")].image}' | cut -f 2 -d 'v')
SNAP=$(kubectl -n ntnx-system get deployment csi-snapshot-controller -o jsonpath='{.metadata.name}' 2> /dev/null)

echo "You are using CSI driver v$VERSION with driver name $DRIVER\n"

if [[ $SNAP = "csi-snapshot-controller" ]]
then
    echo "Your Karbon cluster already support Snapshot Capability"
    exit
fi

if [[ $DRIVER = "csi.nutanix.com" && ( $VERSION = "2.3.1" || $VERSION = "2.2.0" ) ]]
then
    kubectl apply -f https://github.com/nutanix/csi-plugin/releases/download/v$VERSION/snapshot-crd-$VERSION.yaml
    kubectl apply -f https://github.com/nutanix/csi-plugin/releases/download/v$VERSION/karbon-fix-snapshot-$VERSION.yaml
elif [[ $DRIVER = "com.nutanix.csi" && ( $VERSION = "2.3.1" || $VERSION = "2.2.0" ) ]]
then
    kubectl apply -f https://github.com/nutanix/csi-plugin/releases/download/v$VERSION/snapshot-crd-$VERSION.yaml
    kubectl apply -f https://github.com/nutanix/csi-plugin/releases/download/v$VERSION/karbon-fix-snapshot-$VERSION-rev.yaml
else
    echo "**************************************************************************"
    echo "* Untested configuration. Upgrade your Karbon cluster or contact support *"
    echo "**************************************************************************\n"
fi

Create a Volume Snapshot Class

Get the CSI secret name of the default storageclass to create your default snapshotclass:

#!/usr/bin/bash
SECRET=$(kubectl get sc -o=jsonpath='{.items[?(@.metadata.annotations.storageclass\.kubernetes\.io\/is-default-class=="true")].parameters.csi\.storage\.k8s\.io\/provisioner-secret-name}')
DRIVER=$(kubectl get sc -o=jsonpath='{.items[?(@.metadata.annotations.storageclass\.kubernetes\.io\/is-default-class=="true")].provisioner}')

cat << EOF | kubectl apply -f -
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
  name: default-snapshotclass
driver: $DRIVER
parameters:
  storageType: NutanixVolumes
  csi.storage.k8s.io/snapshotter-secret-name: $SECRET
  csi.storage.k8s.io/snapshotter-secret-namespace: kube-system
deletionPolicy: Delete
EOF

Kasten K10 Installation 

Run the Pre-Flight Script

For the purpose of verifying that everything is running correctly, run the following pre-flight script:

helm repo add kasten https://charts.kasten.io --force-update && helm repo update
kubectl create ns kasten-io
kubectl annotate volumesnapshotclass default-snapshotclass k10.kasten.io/is-snapshot-class=true
curl -s https://docs.kasten.io/tools/k10_primer.sh | bash

Namespace option not provided, using default namespace
Checking for tools
 --> Found kubectl
 --> Found helm
 --> Found jq
Checking if the Kasten Helm repo is present
 --> The Kasten Helm repo was found
Checking for required Helm version (>= v3.0.0)
 --> No Tiller needed with Helm v3.12.0
K10Primer image
 --> Using Image (gcr.io/kasten-images/k10tools:6.0.0) to run test
Checking access to the Kubernetes context kasten-context
 --> Able to access the default Kubernetes namespace
K10 Kanister tools image
 --> Using Kanister tools image (ghcr.io/kanisterio/kanister-tools:0.92.0) to run test

Running K10Primer Job in cluster with command-
     ./k10tools primer
serviceaccount/k10-primer created
clusterrolebinding.rbac.authorization.k8s.io/k10-primer created
job.batch/k10primer created
Pod k10primer-fbqbf is in Pending phase
Pod Ready!

Kubernetes Version Check:
  Valid kubernetes version (v1.25.6)  -  OK

RBAC Check:
  Kubernetes RBAC is enabled  -  OK

Aggregated Layer Check:
  The Kubernetes Aggregated Layer is enabled  -  OK

CSI Capabilities Check:
  Using CSI GroupVersion snapshot.storage.k8s.io/v1  -  OK

Validating Provisioners:
csi.nutanix.com:
  Is a CSI Provisioner  -  OK
  Storage Classes:
    default-storageclass
      Valid Storage Class  -  OK
  Volume Snapshot Classes:
    default-snapshotclass
      Has k10.kasten.io/is-snapshot-class annotation set to true  -  OK
      Has deletionPolicy 'Delete'  -  OK

Validate Generic Volume Snapshot:
  Pod created successfully  -  OK
  GVS Backup command executed successfully  -  OK
  Pod deleted successfully  -  OK

serviceaccount "k10-primer" deleted
clusterrolebinding.rbac.authorization.k8s.io "k10-primer" deleted
job.batch "k10primer" deleted

Install Kasten K10 Via Helm Chart

We’re going to install Kasten K10 with minimal options. In this tutorial, we focus mainly on creating policies for protecting namespaces. We won’t be covering authentication, authorization, or how to expose the Kasten K10 dashboard.

helm install k10 kasten/k10 --namespace=kasten-io

NAME: k10
LAST DEPLOYED: Tue Jun 13 12:17:43 2023
NAMESPACE: kasten-io
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Thank you for installing Kasten’s K10 Data Management Platform 6.0.0!

Documentation can be found at https://docs.kasten.io/.

How to access the K10 Dashboard:

To establish a connection to it use the following `kubectl` command:

`kubectl --namespace kasten-io port-forward service/gateway 8080:8000`

The Kasten dashboard will be available at: `http://127.0.0.1:8080/k10/#/`

Next, check that all pods are up and running in the kasten-io namespace:

kubectl get pods -n kasten-io

NAME                                     READY   STATUS    RESTARTS   AGE
aggregatedapis-svc-67c74b4f95-f9kp2      1/1     Running   0          3m19s
auth-svc-9d8b74bd4-rv7hp                 1/1     Running   0          3m20s
catalog-svc-776d77797d-wpmcc             2/2     Running   0          3m19s
controllermanager-svc-56cddc595c-fzhs5   1/1     Running   0          3m18s
crypto-svc-5b94bc4745-plbpv              4/4     Running   0          3m19s
dashboardbff-svc-74865cc684-6j7dl        2/2     Running   0          3m18s
executor-svc-6c867b8d6d-dkq7z            2/2     Running   0          3m20s
executor-svc-6c867b8d6d-vdl7s            2/2     Running   0          3m20s
executor-svc-6c867b8d6d-xxg74            2/2     Running   0          3m20s
frontend-svc-6bfdbdf755-2bt2d            1/1     Running   0          3m19s
gateway-5478cb4695-4kpjc                 1/1     Running   0          3m20s
jobs-svc-6bd67d9cdb-lb5nm                1/1     Running   0          3m20s
k10-grafana-66dcb89d85-9fcmf             1/1     Running   0          3m20s
kanister-svc-6655d95b68-v8z7v            1/1     Running   0          3m19s
logging-svc-7976dc5755-86mpt             1/1     Running   0          3m20s
metering-svc-59696964c-tw7md             1/1     Running   0          3m20s
prometheus-server-6fc67945d9-bm5kg       2/2     Running   0          3m20s
state-svc-7c47546979-5m6ds               2/2     Running   0          3m20s

Test the Snapshot, Backup, and Recovery of an Application 

Install the Test Application

Here, we test Kasten’s backup and recovery capabilities on a mysql application running on Karbon clusters:

kubectl create namespace mysql
cat << EOF | kubectl apply -f -
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mysql
  namespace: mysql
spec:
  selector:
    matchLabels:
      app: mysql
  serviceName: mysql
  replicas: 1
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
      - name: mysql
        image: mysql:8.0
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: ultrasecurepassword   
        ports:
        - containerPort: 3306
          name: mysql
        volumeMounts:
        - name: data
          mountPath: /var/lib/mysql
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 5Gi

EOF

We’ll then populate the database with some data once the mysql pod is ready:

kubectl exec -ti mysql-0 -n mysql -- bash

mysql --user=root --password=ultrasecurepassword
CREATE DATABASE test;
USE test;
CREATE TABLE pets (name VARCHAR(20), owner VARCHAR(20), species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
INSERT INTO pets VALUES ('Puffball','Diane','hamster','f','1999-03-30',NULL);
INSERT INTO pets VALUES ('Tsarine','Cris','exotic','f','2022-06-25',NULL);
SELECT * FROM pets;
+----------+-------+---------+------+------------+-------+
| name     | owner | species | sex  | birth      | death |
+----------+-------+---------+------+------------+-------+
| Puffball | Diane | hamster | f    | 1999-03-30 | NULL  |
| Tsarine  | Cris  | exotic  | f    | 2022-06-25 | NULL  |
+----------+-------+---------+------+------------+-------+
2 row in set (0.00 sec)

Snapshot the Application 

From this point onward, operations will be performed on the dashboard, which we’ll need to make available via port-forwarding:

kubectl --namespace kasten-io port-forward service/gateway 8080:8000

The Kasten K10 dashboard will be available at: http://127.0.0.1:8080/k10/#/ 

Accept the end user license agreement.

In a production context, the dashboard would be exposed through an Ingress Controller with the correct authentication subsystem configured.

We’re now going to snapshot the application, which involves capturing the complete state of the application without exporting it to an external storage.

Go to Applications –> MySQL –> Create a Policy

Name: mysql-backup  Action: Snapshot  Action Frequency: Daily Sub-hourly Frequencies: <default>

Snapshot Retention: <default> Select Applications: <default> Resources: <default>

Select ‘Create Policy’:

Click the ‘run once’ button, shown below:

Now, go to the main dashboard and scroll down under ‘Actions’ to view progress:

After the circle turns solid green, click on the job to open a details pane and view all artifacts that were captured:

Back up the application

Backing up the application means exporting the snapshot to an external object store. Before doing so, we need to carve out that resource. 

Create an external object store with Nutanix Objects

We’ll use Nutanix Objects to enable object storage services on a remote cluster in order to receive the Kasten Backup export. 

We assume that an Object Store is already deployed on a different Nutanix cluster than the one where the Karbon Kubernetes Cluster is deployed.

We’ll then use Prism Central to connect the Object Store, create a new Bucket, and add a user.

In Prism Central, go to Services -> Objects and click ‘Access Keys’.

Next, we’ll add a new user. Click ‘Add People’:

Select ‘Add people not in a directory service’ and fill in the ‘Email’ and ‘Name’ fields. Then click ‘Next’.

Generate keys and download them:

This process downloads a text file containing your access and secret key, shown below:

Next, return to ‘Object Stores’ and click on the S3 Object Store that you created earlier:

Now, create a new bucket:

Select the bucket you just created and go to ‘User Access’:

Edit user access to give read and write permissions to the user you created earlier:

We’re now done with Nutanix Objects. We’re almost there!

Setting Up the Location Profile on the Kasten K10 Dashboard

In the Kasten UI, go to Settings -> Location Profile -> New Profile -> S3 compatible 

Name the profile ‘object-storage’ and then fill out the rest of information requested.

S3 Access Key and S3 Secret will be taken from the key file downloaded in the previous step.

Note that ‘Endpoint’ corresponds to the URL of your object store from the Nutanix UI.

‘Bucket Name’ should correspond to the name of the bucket you previously created.

Now, click ‘Save Profile’.

Change the Policy to Add an Export Profile

Find the appropriate policy under Dashboard –> Policies, then click ‘Edit’.

Next, select ‘Enable Backups via Snapshot Exports’ and select the appropriate profile in the drop-down menu:

Click ‘Edit Policy’ and then click ‘Run’ once again.

Now, navigate to the main dashboard and scroll down under ‘Actions’ in order to view progress:

The export will execute after the backup process completes. 

When the green progress circle is complete, click on the job to open a ‘details’ pane to view all of the artifacts that were captured.

Restoring the Application

If you go back to the restore point view, you can see that we now we have two restore points: a local restore point and an exported restore point.

The exported restore point can be used even if the namespace is deleted, or even if the cluster itself is deleted. The restore point can also be restored to another cluster where Kasten is installed.

Now, let’s delete the mysql namespace:

kubectl delete ns mysql

Use the exported restore point and click on ‘Restore’ without changing anything.

Let’s now check that our data is back:

kubectl exec -ti mysql-0 -n mysql -- bash

mysql --user=root --password=ultrasecurepassword
USE test;
SELECT * FROM pets;
mysql> SELECT * FROM pets;
+----------+-------+---------+------+------------+-------+
| name     | owner | species | sex  | birth      | death |
+----------+-------+---------+------+------------+-------+
| Puffball | Diane | hamster | f    | 1999-03-30 | NULL  |
| Tsarine  | Me    | exotic  | f    | 2022-06-25 | NULL  |
+----------+-------+---------+------+------------+-------+
2 row in set (0.00 sec)

As expected, all data is intact and the restoration was successful!

Summary

Stateful workloads are no longer a major issue for Kubernetes administrators. The combination of Nutanix Karbon for management of production-grade Kubernetes clusters, Kasten K10 by Veeam for backup and recovery of data, and Nutanix Objects as an S3-compatible object storage repository is a complete solution for deploying stateful Cloud Native applications with the level of resiliency and reliability you would expect from traditional on-premises infrastructure.

© 2024 Nutanix, Inc. All rights reserved. Nutanix, the Nutanix logo and all Nutanix product, feature and service names mentioned herein are registered trademarks or trademarks of Nutanix, Inc. in the United States and other countries. Other brand names mentioned herein are for identification purposes only and may be the trademarks of their respective holder(s). This post may contain links to external websites that are not part of Nutanix.com. Nutanix does not control these sites and disclaims all responsibility for the content or accuracy of any external site. Our decision to link to an external site should not be considered an endorsement of any content on such a site. Certain information contained in this post may relate to or be based on studies, publications, surveys and other data obtained from third-party sources and our own internal estimates and research. While we believe these third-party studies, publications, surveys and other data are reliable as of the date of this post, they have not independently verified, and we make no representation as to the adequacy, fairness, accuracy, or completeness of any information obtained from third-party sources.