Persist Application PVC Data During SMCP Upgrade

Problem

  • Any non-SMCP components deployed on the management plane including PVC data gets lost post management plane upgrade.

Environment

  • Self Managed Cloud Platform (SMCP) 5.9 and Higher

  • Any PVC backed custom workload applications.

Cause

The SMCP Management Plane upgrade is designed in a way to take the backup of the Management Plane components and destroy the cluster and create new Management Plane cluster in required version and then restore the backup.

During the backup process, no data/volume other than Platform9 components are preserved. The custom data will be lost.

Resolution

The steps to backup the volumes associated with the required application pod's PV/PVC are mentioned below.

circle-info

NOTE:

As an example, a busybox application's volume is being backed here by PVC. The StatefulSet yaml file associated is mentioned below:

apiVersion: apps/v1
kind: StatefulSet
metadata:
  creationTimestamp: null
  labels:
    app: busybox
  name: busybox
spec:
  replicas: 3
  selector:
    matchLabels:
      app: busybox
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: busybox
    spec:
      containers:
      - image: busybox
        name: busybox
        resources: {}
        command: ["/bin/sh"]
        args: ["-c", "sleep 600"]
        volumeMounts:
        - name: bb-volume
          mountPath: /mydata
  volumeClaimTemplates:
  - metadata:
      name: bb-volume
      namespace: default
    spec:
      storageClassName: local-path
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 500Mi
status: {}

BEFORE UPGRADE

  • Perform graceful shutdown of the pods, wait till they are properly removed

  • Identify the three busybox PVCs and match the name to the directory on disk. On each of the three nodes, move the PVC directory to the top level of /opt

  • Take backup of all three PVCs and PVs. Ensure to repeat the same for the other two PVCs and PVs.

  • Edit all three PV backup files generated above and comment out the claimRef section.

  • Upgrade the SMCP Management Plane to the desired version.

AFTER UPGRADE

  • Move the PVC data on the disk, back into the original directory on each node. Repeat this step on all three nodes for respective PVC.

  • Re-apply the PVs and PVCs.

IMPORTANT

Start with the PVs that contains the commented out claimRef, followed by the associated PVCs.

  • Apply the PVC post applying PV; the PVC should show Bound status. Repeat this with other PVCs & PVs.

  • Redeploy the application. The pods should attach to the volumes successfully and the previous data from the volumes will be utilised.

Last updated