Interview's MateKubernetes
Interview's Mate

Kubernetes

K8s · Workloads · GitOps · Cloud

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Kubernetes topics
Lesson 77/ 160
04. Storage & Persistent Data

Migrating Persistent Volumes Across Clusters

Move stateful data between clusters with snapshots, restores, or replication tools.

AdvancedPV Migration · Cross-Cluster · Replication3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

PV migration is moving the sealed warehouse inventory and then registering its boxes in the destination warehouse's local catalog. The simple Kubernetes rule is: PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover.

Think of it like…

PV migration is moving the sealed warehouse inventory and then registering its boxes in the destination warehouse's local catalog.

Where you’ve seen it

Before approving a data-path change, the storage owner runs velero backup create migrate; kubectl get volumesnapshot,pvc; kubectl exec restore-job -- test -f /data/CHECKSUM. Expected evidence: PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover. If the run instead shows this symptom, stop and restore the last known state: CSI snapshots are usually not portable across providers or regions, and copying bytes without checking encryption keys, filesystem UUIDs, and database write order can make a clean restore unusable.

Words you’ll hear

PV Migration
For this lesson, PV Migration is the controlling idea: PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover.
Cross-Cluster
Cross-Cluster is the checkpoint; run velero backup create migrate; kubectl get volumesnapshot,pvc; kubectl exec restore-job -- test -f /data/CHECKSUM and inspect the owner chain. CSI snapshots are usually not portable across providers or regions, and copying bytes without checking encryption keys, filesystem UUIDs, and database write order can make a clean restore unusable.
Replication
Replication is the outcome to preserve; the cost is explicit: Replication minimizes downtime but adds cost and complexity; offline copy is simpler but freezes service and requires a tested reverse plan.
Verification evidence
The evidence command is velero backup create migrate; kubectl get volumesnapshot,pvc; kubectl exec restore-job -- test -f /data/CHECKSUM. It connects the declaration to this behavior: Move stateful data between clusters with snapshots, restores, or replication tools.

Visual diagram

Loading interactive diagram

Theory & deep dive

How PV Migration reaches the intended state

Move stateful data between clusters with snapshots, restores, or replication tools. PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover.

The concrete checkpoint is velero backup create migrate; kubectl get volumesnapshot,pvc; kubectl exec restore-job -- test -f /data/CHECKSUM; compare the PV Migration owner, Cross-Cluster state, and Replication outcome instead of treating YAML acceptance as proof.

Verify Cross-Cluster, not only object creation

Run velero backup create migrate; kubectl get volumesnapshot,pvc; kubectl exec restore-job -- test -f /data/CHECKSUM after the change and correlate the result with Events and the owning object. PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover.

Key takeaway: PV Migration is implemented only when this invariant remains observable: PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover.

Cross-Cluster: failure boundary and production cost

CSI snapshots are usually not portable across providers or regions, and copying bytes without checking encryption keys, filesystem UUIDs, and database write order can make a clean restore unusable. The prerequisite contract is concrete: PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover.

Replication minimizes downtime but adds cost and complexity; offline copy is simpler but freezes service and requires a tested reverse plan. A safe design limits blast radius, records the last good configuration, and uses velero backup create migrate; kubectl get volumesnapshot,pvc; kubectl exec restore-job -- test -f /data/CHECKSUM as a deterministic rollback checkpoint.

Recover from Cross-Cluster drift

Capture the current state with velero backup create migrate; kubectl get volumesnapshot,pvc; kubectl exec restore-job -- test -f /data/CHECKSUM, then correct the controlling manifest rather than patching a child object; the relevant divergence signal is specific: CSI snapshots are usually not portable across providers or regions, and copying bytes without checking encryption keys, filesystem UUIDs, and database write order can make a clean restore unusable.

Key takeaway: Accept the trade-off consciously: Replication minimizes downtime but adds cost and complexity; offline copy is simpler but freezes service and requires a tested reverse plan.

How it works, step by step

Step 1 of 4
Data owner

1. Declare the data contract

State capacity, topology, access, and ownership in the claim or class: PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover.

PV Migration contract → owned state
Key numbers at this step
Goal
Move stateful data between clusters with snapshots, restores, or replication tools.
Owner
PV Migration

When to use it & trade-offs

What it is

Move stateful data between clusters with snapshots, restores, or replication tools. PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover.

Why it matters: CSI snapshots are usually not portable across providers or regions, and copying bytes without checking encryption keys, filesystem UUIDs, and database write order can make a clean restore unusable. The invariant at risk is specific: PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover. The quickest fact check before changing the design is velero backup create migrate; kubectl get volumesnapshot,pvc; kubectl exec restore-job -- test -f /data/CHECKSUM.

When to reach for it

  • Use PV Migration to enforce this invariant: PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover.
  • Use Cross-Cluster evidence from velero backup create migrate; kubectl get volumesnapshot,pvc; kubectl exec restore-job -- test -f /data/CHECKSUM in reviews and incident timelines. Move stateful data between clusters with snapshots, restores, or replication tools.
  • Choose the managed external data plane route only when this cost is justified by governance or scale: Replication minimizes downtime but adds cost and complexity; offline copy is simpler but freezes service and requires a tested reverse plan.

When to avoid or be careful

  • Avoid assuming PV Migration is complete after YAML submission; the required behavior is concrete: PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover.
  • Avoid treating the next symptom as random; check the owner and state with velero backup create migrate; kubectl get volumesnapshot,pvc; kubectl exec restore-job -- test -f /data/CHECKSUM first: CSI snapshots are usually not portable across providers or regions, and copying bytes without checking encryption keys, filesystem UUIDs, and database write order can make a clean restore unusable.
  • Avoid adopting a heavier platform wrapper before measuring its cost: Replication minimizes downtime but adds cost and complexity; offline copy is simpler but freezes service and requires a tested reverse plan.

Native, manual, and managed paths for PV Migration

Dynamically provisioned storage
Best for: Move stateful data between clusters with snapshots, restores, or replication tools. A concrete incident check is velero backup create migrate; kubectl get volumesnapshot,pvc; kubectl exec restore-job -- test -f /data/CHECKSUM.

Strengths: PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover.

Watch out: Replication minimizes downtime but adds cost and complexity; offline copy is simpler but freezes service and requires a tested reverse plan. Recovery must also recognize this signal: CSI snapshots are usually not portable across providers or regions, and copying bytes without checking encryption keys, filesystem UUIDs, and database write order can make a clean restore unusable.

Manual pre-provisioning
Best for: Quickly testing the Cross-Cluster assumption with velero backup create migrate; kubectl get volumesnapshot,pvc; kubectl exec restore-job -- test -f /data/CHECKSUM; the expected invariant is: PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover.

Strengths: velero backup create migrate; kubectl get volumesnapshot,pvc; kubectl exec restore-job -- test -f /data/CHECKSUM gives immediate feedback without first building a platform layer.

Watch out: A manual change can hide drift, and unlike PV Migration, it does not make this symptom self-documenting: CSI snapshots are usually not portable across providers or regions, and copying bytes without checking encryption keys, filesystem UUIDs, and database write order can make a clean restore unusable.

Managed external data plane
Best for: Teams that need Replication integrated with guardrails; the evidence path is velero backup create migrate; kubectl get volumesnapshot,pvc; kubectl exec restore-job -- test -f /data/CHECKSUM.

Strengths: Platform controls can wrap this exact behavior in policy or dashboards: PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover.

Watch out: The added platform ownership buys value at this cost: Replication minimizes downtime but adds cost and complexity; offline copy is simpler but freezes service and requires a tested reverse plan.

Interview signals & numbers to know

When this topic comes up

  • Interview anchor: PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover.
  • Trace PV Migration to Replication through Cross-Cluster; the invariant is: PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover.
  • Recognize the symptom: CSI snapshots are usually not portable across providers or regions, and copying bytes without checking encryption keys, filesystem UUIDs, and database write order can make a clean restore unusable.
  • Justify the cost: Replication minimizes downtime but adds cost and complexity; offline copy is simpler but freezes service and requires a tested reverse plan.
  • Verify with velero backup create migrate; kubectl get volumesnapshot,pvc; kubectl exec restore-job -- test -f /data/CHECKSUM instead of only inspecting YAML.

Benchmarks & rules of thumb

2 -
clusters must be coordinated: source and destination
3 -
cutover gates: consistent copy, checksum, and application health
0 -
assumption that a source StorageClass exists at the destination

Common mistakes & follow-ups

Common interview mistakes

  • Debugging only the child object misses the PV Migration owner contract: PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover.
  • Ignoring this telltale condition leads to unrelated changes: CSI snapshots are usually not portable across providers or regions, and copying bytes without checking encryption keys, filesystem UUIDs, and database write order can make a clean restore unusable.
  • Repeating velero backup create migrate; kubectl get volumesnapshot,pvc; kubectl exec restore-job -- test -f /data/CHECKSUM without an owner for remediation wastes retry cost. Replication minimizes downtime but adds cost and complexity; offline copy is simpler but freezes service and requires a tested reverse plan.

Likely interviewer follow-ups

  • How would API output and runtime evidence prove this behavior: PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover?
  • Which owner object, logs, and Events would you inspect for this symptom-CSI snapshots are usually not portable across providers or regions, and copying bytes without checking encryption keys, filesystem UUIDs, and database write order can make a clean restore unusable-?
  • At what threshold would this cost become unacceptable: Replication minimizes downtime but adds cost and complexity; offline copy is simpler but freezes service and requires a tested reverse plan?
Interview tip: Interview sequence: state the invariant, run velero backup create migrate; kubectl get volumesnapshot,pvc; kubectl exec restore-job -- test -f /data/CHECKSUM, name the failure, then justify the cost. Invariant: PV migration moves an application-consistent snapshot, storage replication stream, or file-level copy and recreates claims under target classes and topology before endpoint cutover. Failure: CSI snapshots are usually not portable across providers or regions, and copying bytes without checking encryption keys, filesystem UUIDs, and database write order can make a clean restore unusable. Cost: Replication minimizes downtime but adds cost and complexity; offline copy is simpler but freezes service and requires a tested reverse plan.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Migrating Persistent Volumes Across Clusters with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Backup & Disaster Recovery with Velero
Next topic
Storage Performance Tuning (IOPS, Throughput, Node Attachment Limits)