Home > other >  How to restore pv/pvc by AWS EBS Backup Recovery points
How to restore pv/pvc by AWS EBS Backup Recovery points

Time:10-31

I created a gp2 storageclass in my eks cluster. When I create a statefulset instance, it will automatically creates a volume in AWS's EBS.

I backed up the mounted volumes bound to statefulset by using AWS's Backup service. But after I restore the Recovery point, it just created a newly mounted volume with a different name. How do I bind this new volume to statefulset's pod?

I tried to edit pv/pvc yaml but failed.

CodePudding user response:

If you are using the volumeClaimTemplates in your YAML definition. it will use the create unique replicas for stateful sets with postfix -0, -1.

If you have already created the new PVC you and mount it to statefulset simply as the normal way we do in deployment with volume.

Example

apiVersion: "apps/v1"
kind: StatefulSet
metadata:
  name: busybox
spec:
  serviceName: busybox
  replicas: 1
  template:
    metadata:
      labels:
        app: busybox
    spec:
      containers:
        - name: busybox-container 
          image: "busybox"
          imagePullPolicy: "IfNotPresent"
          volumeMounts: 
            - name: volume
              mountPath: /tmp
      volumes:
        - name: volume
          persistentVolumeClaim:
            claimName: already-volume-claim

if you have multiple replicas running and have multiple PVC to attach you can use the volumeClaimTemplates itself.

ref link : Using a pre-existing disk in a StatefulSet

  • Related