-1

I have an AWS EKS cluster. Lets call it EKS-1, in which I had a stateful set with a PVC and PV that provisioned a EBS volume in AWS dynamically. I deleted the Stateful set and the PVC. The PV is in available status and its volume in AWS is also intact.

Now I have a second cluster EKS-2 in which I have deployed a stateful set that created a PVC and a PV. Now I want to use the AWS EBS volume created by EKS-1 as a PV for the staefulsset in EKS-2.

How can we do that ?

RAMNEEK GUPTA
  • 713
  • 1
  • 6
  • 13

1 Answers1

0

You have Two options either you use the same EBS volume to EKS cluster-2 or you clone the data from EKS-1 EBS to EKS-2 EBS(new volume but data cloned).

Option : 1

Before you move ahead make sure PVC is not attached to PV for EKS-1 cluster, we will use this EBS volume to EKS-2 cluster.

Create the YAML config and apply

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-data
spec:
  accessModes:
  - ReadWriteOnce
  awsElasticBlockStore:
    fsType: ext4
    volumeID: aws://eu-west-2a/Vol_Details
  capacity:
    storage: 60Gi
  persistentVolumeReclaimPolicy: Retain
  storageClassName: gp2
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  labels:
    app.kubernetes.io/name: <app-name>
  name: pvc-name
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 60Gi
  storageClassName: gp2
  volumeName: pv-data

Once you create the PV with existing EBS volume you will be able to create the PVC also & further you will be able to create statefulsets and use it.

Option : 2

Cloning the data across Cluster

You can leverage the Tool like velero, to clone the data. Which will take the snapshot of your EBS on EKS-1 save config data to Bucket, on EKS-2 you will setup velero and restore those data details from Bucket.

You will be able to take full snapshot also PV, PVC, Statefulset also or single resource also as per need.

Here you can follow my article using the Velero, i have used the GCS plugin but you can use the AWS & S3 option instead : https://medium.com/@harsh.manvar111/backup-and-restore-elasticsearch-using-gcs-fa70003b9b5e

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102