Skip to main content

KASTEN A to Z Day 5 Installing a simple application with persistent storage


Geoff Burke
Forum|alt.badge.img+22

We are back after a week off!

This will be a quick demo of snapshot creation. I am doing this on another cluster on purpose just to show that the commands we are using should work everywhere. Next week when we create a Kasten policy we will do so on our Longhorn storage setup. 

In this episode I am leveraging the csi-hostpat-driver to leverage local storage on my laptop. There are instructions here on the Korner on how to setup that up. If you have any problems finding those or have issues with the installation please reach out to me. 

Today we will install a simple application in a Kubernetes cluster then create a simple snapshot of the application by leveraging Kasten.

First we will create a new namespace for our nginx application and then we will create two manifest files, the first a persistent volume claim, or pvc which will request storage from our cluster. 

The second file will be our application manifest which will specify what container image to use among other things.

Create a namespace called nginx

kubectl create ns nginx

Create the following pvc manifest file pvc.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: task-pv-claim
  namespace: nginx
spec:
  storageClassName: csi-hostpath-sc
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

Next create the nginx application manifest file, this file will leverage the pvc that we just wrote the manifest for above:

pod.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: task-pv-claim
  namespace: nginx
spec:
  storageClassName: csi-hostpath-sc
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
apiVersion: v1
kind: Pod
metadata:
  name: task-pv-pod
  namespace: nginx
spec:
  volumes:
    - name: task-pv-storage
      persistentVolumeClaim:
        claimName: task-pv-claim
  containers:
    - name: task-pv-container
      image: nginx
      ports:
        - containerPort: 80
          name: "http-server"
      volumeMounts:
        - mountPath: "/usr/share/nginx/html"
          name: task-pv-storage

Next apply both files:

kubectl apply -f pvc.yaml 

kubectl apply -f pod.yaml

We should see this:

pvc and pod have been created

So now we have an nginx pod running with 1GB of persistent storage.

 

If we look at the pod manifest we will see that our persistent storage is being mounted in the pod at /usr/share/nginx/html.

Let’s put some data in that location to backup.

For another project linked to IAM/STS and S3 😀I have been playing around with the aws cli and I just happen to have the zip download client file available. I will copy that into the running container in the location of the persistent storage.

kubectl cp awscliv2.zip -n nginx task-pv-pod:/usr/share/nginx/html

You can copy any file you wish.

Then let’s go into the pod and check to see if the data is there:

kubectl exec -n nginx task-pv-pod -it -- bash

cd /usr/share/nginx/html

ls
File is there!

Now lets go to Kasten and perform a simple local snapshot:

Go to Applications in the Dashboard and find the nginx namespace:

nginx namespace

Click on the menu over to the right and choose Snapshot

Snapshot

This will create a manual snapshot:

Manual Snapshot
Done

Now if you go back to that menu and click restore you will see an available local snapshot for restoring:

 

Available Snapshot

 

Next week we will create a Policy that can be scheduled with retention!

1 comment

Chris.Childerhose
Forum|alt.badge.img+21
  • Veeam Legend, Veeam Vanguard
  • 8492 comments
  • July 27, 2024

Another great post in the Kasten series.  👍


Comment