Performing Kubernetes volume and volume group snapshots with Portworx

In this post I am going to show how we can take volume and volume group snapshots with Portworx.

I have previous blogged on how you can run an Oracle 19c on Kubernetes with Portworx and will use the PVCs created that blog within this post.

Inspect existing Statefulset

Before we start let’s looks out current Oracle 19c statefulset, we can do this with kubectl get statefulset

[root@master-1 ~]# kubectl get statefulset --all-namespaces -l app=database
NAMESPACE          NAME        READY   AGE
oracle-namespace   oracle19c   1/1     26d

The running pods.

[root@master-1 ~]# kubectl get pods -n oracle-namespace -l app=database
NAME          READY   STATUS    RESTARTS   AGE
oracle19c-0   1/1     Running   0          18d

And the PVC’s (Persistent Volume claims).

[root@master-1 ~]# kubectl get pvc -l app=database -n oracle-namespace
NAME                      STATUS VOLUME                                 CAPACITY ACCESS MODES STORAGECLASS   
ora-data193-oracle19c-0    Bound pvc-597ea109-44cd-409b-94ac-942e6689b714   20Gi     RWO      px-ora-sc      
ora-setup193-oracle19c-0   Bound pvc-9d8e8157-7390-4834-a496-121a5b8bff94    1Gi     RWO      px-ora-sc      
ora-startup193-oracle19c-0 Bound pvc-d449ae0a-240f-4a28-9c81-718d8b8f968a    1Gi     RWO      px-ora-sc      

From the above I can see my 3 PVC’s (data, setup and startup) are using a StorageClass of px-ora-sc, we can inspect this with kubectl describe storageclass or using the short name sc.

[root@master-1 ~]# kubectl describe sc px-ora-sc
Name:            px-ora-sc
IsDefaultClass:  No
Annotations:     kubectl.kubernetes.io/last-applied-configuration={"allowVolumeExpansion":true,"apiVersion":"storage.k8s.io/v1beta1","kind":"StorageClass","metadata":{"annotations":{},"name":"px-ora-sc"},"parameters":{"io_profile":"db","priority_io":"high","repl":"3"},"provisioner":"kubernetes.io/portworx-volume"}
 
Provisioner:           kubernetes.io/portworx-volume
Parameters:            io_profile=db,priority_io=high,repl=3
AllowVolumeExpansion:  True
MountOptions:          <none>
ReclaimPolicy:         Delete
VolumeBindingMode:     Immediate
Events:                <none>

Create volume Snapshot

Now we know the details of our environment we can take a snapshot of our Kubernetes PVC using a VolumeSnapshot.

apiVersion: volumesnapshot.external-storage.k8s.io/v1
 kind: VolumeSnapshot
 metadata:
   name: ora-data193-snap
   namespace: oracle-namespace
 spec:
   persistentVolumeClaimName: ora-data193-oracle19c-0

Create volume snapshot

[root@master-1 ~]# kubectl create -f px-oradata-snap.yaml
volumesnapshot.volumesnapshot.external-storage.k8s.io/ora-data193-snap created

We can see out snapshot by using kubectl get volumesnapshot

[root@master-1 Oracle-on-Kubernetes]# kubectl get volumesnapshot -n oracle-namespace
NAME               AGE
ora-data193-snap   2m23s

[root@master-1 Oracle-on-Kubernetes]# kubectl get volumesnapshotdatas -n oracle-namespace
NAME                                                       AGE
k8s-volume-snapshot-2e6a90be-13ba-48c2-a87e-d09d435e2074   2m42s

We can find additional details with kubectl describe volumesnapshot

[root@master-1 ~]# kubectl describe volumesnapshot/ora-data193-snap -n oracle-namespace
Name:         ora-data193-snap
Namespace:    oracle-namespace
Labels:       SnapshotMetadata-PVName=pvc-597ea109-44cd-409b-94ac-942e6689b714
              SnapshotMetadata-Timestamp=1608812262265619232
Annotations:  <none>
API Version:  volumesnapshot.external-storage.k8s.io/v1
Kind:         VolumeSnapshot
Metadata:
  Creation Timestamp:  2020-12-24T12:17:57Z
  Generation:          3
  Resource Version:    16440668
  Self Link:           /apis/volumesnapshot.external-storage.k8s.io/v1/namespaces/oraclenamespace/volumesnapshots/ora-data193-snap
  UID:                 08baaf75-df6c-4fa8-ab59-fa8c4994d589
Spec:
  Persistent Volume Claim Name:  ora-data193-oracle19c-0
  Snapshot Data Name:            k8s-volume-snapshot-2e6a90be-13ba-48c2-a87e-d09d435e2074
Status:
  Conditions:
    Last Transition Time:  2020-12-24T12:17:43Z
    Message:               Snapshot created successfully and it is ready
    Reason:                
    Status:                True
    Type:                  Ready
  Creation Timestamp:      <nil> 
Events:                    <none>

Create Group Volume Snapshot

For this we will use STORK (STorage Orchestrator Runtime for Kubernetes) and a pvcSelector to specify a label selector which will match all PVCs that have the label e.g. app=database

apiVersion: stork.libopenstorage.org/v1alpha1
kind: GroupVolumeSnapshot
metadata:
  name: oracle-snap
spec:
  pvcSelector:
    matchLabels:
      app: database
  restoreNamespaces:
   - default

Create group volume snapshot

[root@master-1 ~]# kubectl create -f px-oracle-snap.yaml
groupvolumesnapshot.stork.libopenstorage.org/oracle-snap created
[root@master-1 ~]# kubectl get groupvolumesnapshot oracle-snap
NAME          AGE
oracle-snap   56s

Using kubectl get volumesnapshotdatas we can that our group volume snapshot includes the 3 PVC’s.

[root@master-1 ~]# kubectl get volumesnapshotdatas -n oracle-namespace
NAME                                                                          AGE
oracle-snap-ora-data193-oracle19c-0-fcdf67fb-00cd-4881-a22e-39ebd50c5d0f      39m
oracle-snap-ora-setup193-oracle19c-0-fcdf67fb-00cd-4881-a22e-39ebd50c5d0f     39m
oracle-snap-ora-startup193-oracle19c-0-fcdf67fb-00cd-4881-a22e-39ebd50c5d0f   39m

And we can use kubectl describe groupvolumesnapshot

[root@master-1 ~]# kubectl describe groupvolumesnapshot oracle-snap
Name:         oracle-snap
Namespace:    oracle-namespace
Labels:       <none>
Annotations:  <none>
API Version:  stork.libopenstorage.org/v1alpha1
Kind:         GroupVolumeSnapshot
Metadata:
  Creation Timestamp:  2020-12-24T12:35:11Z
  Finalizers:
    stork.libopenstorage.org/finalizer-cleanup
  Generation:        5
  Resource Version:  16445297
  Self Link:      /apis/stork.libopenstorage.org/v1alpha1/namespaces/oraclenamespace/groupvolumesnapshots/oracle-snap
  UID:               fcdf67fb-00cd-4881-a22e-39ebd50c5d0f
Spec:
  Max Retries:     0
  Options:         <nil>
  Post Exec Rule:  
  Pre Exec Rule:   
  Pvc Selector:
    Match Labels:
      App:  database
  Restore Namespaces:
    default
Status:
  Num Retries:  0
  Stage:        Final
  Status:       Successful
  Volume Snapshots:
    Conditions:
      Last Transition Time:  2020-12-24T12:34:57Z
      Message:               Snapshot created successfully and it is ready
      Reason:                
      Status:                True
      Type:                  Ready
    Data Source:
      Portworx Volume:
        Snapshot Id:       458382712379994692
        Snapshot Type:     local
    Parent Volume ID:      294971258389775803
    Task ID:               
    Volume Snapshot Name:  oracle-snap-ora-setup193-oracle19c-0-fcdf67fb-00cd-4881-a22e-39ebd50c5d0f
    Conditions:
      Last Transition Time:  2020-12-24T12:34:57Z
      Message:               Snapshot created successfully and it is ready
      Reason:                
      Status:                True
      Type:                  Ready
    Data Source:
      Portworx Volume:
        Snapshot Id:       1033204856731615129
        Snapshot Type:     local
    Parent Volume ID:      388848998479155218
    Task ID:               
    Volume Snapshot Name:  oracle-snap-ora-data193-oracle19c-0-fcdf67fb-00cd-4881-a22e-39ebd50c5d0f
    Conditions:
      Last Transition Time:  2020-12-24T12:34:57Z
      Message:               Snapshot created successfully and it is ready
      Reason:                
      Status:                True
      Type:                  Ready
    Data Source:
      Portworx Volume:
        Snapshot Id:       452388327165315351
        Snapshot Type:     local
     Parent Volume ID:      595011029224546858
     Task ID:               
     Volume Snapshot Name:  oracle-snap-ora-startup193-oracle19c-0-fcdf67fb-00cd-4881-a22e-39ebd50c5d0f
 Events:                    <none>

Summary

In this blog I have shown how we can take volume and volume Group Snapshots, in my next post we look at restoring snapshots.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: