restore-pvc.yaml


Overview

The `restore-pvc.yaml` file is a Kubernetes manifest designed to facilitate the **restoration of Persistent Volumes (PV) and Persistent Volume Claims (PVC)** within a Kubernetes cluster. Specifically, it supports the **manual restore workflow** for stateful applications (such as blockchain nodes or indexers) that rely on AWS Elastic Block Store (EBS) volumes for persistent data storage.

This file defines the **binding between a restored EBS volume and the Kubernetes StatefulSet pod**, enabling the pod to resume operation from a snapshot-derived volume. It ensures that Kubernetes correctly attaches the restored volume with the appropriate storage class, capacity, node affinity, and access modes.

In essence, this manifest acts as the critical link between AWS EBS volumes restored from snapshots and Kubernetes workloads, allowing for controlled recovery of persistent state after data corruption, failure, or migration.


Detailed Explanation

The YAML manifest consists of two main Kubernetes resources:

These resources work together to bind storage volumes to pods running in the cluster.


PersistentVolume (PV)

Purpose

The PV object represents a piece of storage in the cluster. In this file, the PV points to an AWS EBS volume that has been restored from a snapshot.

Key Fields

Usage Example

apiVersion: v1
kind: PersistentVolume
metadata:
  name: data-ethereum-sts-0-pv-dev
spec:
  capacity:
    storage: 200Gi
  accessModes:
    - ReadWriteOnce
  csi:
    driver: ebs.csi.aws.com
    fsType: ext4
    volumeHandle: vol-0abcd1234efgh5678
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
          - key: topology.ebs.csi.aws.com/zone
            operator: In
            values:
            - us-east-2a
  persistentVolumeReclaimPolicy: Retain
  storageClassName: gp3
  volumeMode: Filesystem

PersistentVolumeClaim (PVC)

Purpose

The PVC is a request for storage by a Kubernetes pod. It claims the PV defined above, enabling pods to mount the restored EBS volume.

Key Fields

Usage Example

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: data-ethereum-sts-0
  annotations:
    ebs.csi.aws.com/iops: "3000"
    ebs.csi.aws.com/throughput: "125"
  namespace: blockchain
  labels:
    app: unchained
    asset: ethereum
    tier: statefulservice
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 200Gi
  storageClassName: gp3
  volumeName: data-ethereum-sts-0-pv-dev

Important Implementation Details


How This File Interacts with Other Parts of the System


Visual Diagram: Workflow of restore-pvc.yaml

flowchart TD
    A[Start Restore Process] --> B[Scale Down StatefulSet]
    B --> C[Delete Existing PVC & PV]
    C --> D[Create New EBS Volume from Snapshot]
    D --> E[Edit & Apply restore-pvc.yaml]
    E --> F[Kubernetes Creates PV Object]
    F --> G[Kubernetes Creates PVC Object]
    G --> H[PV and PVC Bound Together]
    H --> I[StatefulSet Pod Mounts PVC]
    I --> J[Scale Up StatefulSet]
    J --> K[Pod Uses Restored Volume]

Summary

The `restore-pvc.yaml` file is a **critical Kubernetes manifest** used to manually restore persistent storage volumes from AWS EBS snapshots in a Kubernetes environment. It defines a PersistentVolume that points to a restored EBS volume and a PersistentVolumeClaim that requests that storage for a pod.

By carefully crafting and applying this YAML, operators can **recover stateful workloads** with minimal downtime and ensure data consistency during restore operations. This file fits into the broader Snapshot & Restore process by bridging AWS volume restoration and Kubernetes pod volume attachment.


References


If you have any questions or need examples tailored to specific workloads, please ask!