惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
MongoDB | Blog
MongoDB | Blog
Google DeepMind News
Google DeepMind News
L
LangChain Blog
J
Java Code Geeks
MyScale Blog
MyScale Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
WordPress大学
WordPress大学
小众软件
小众软件
Microsoft Security Blog
Microsoft Security Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
aimingoo的专栏
aimingoo的专栏
F
Fortinet All Blogs
I
InfoQ
博客园 - 聂微东
量子位
A
About on SuperTechFans
S
SegmentFault 最新的问题
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
云风的 BLOG
云风的 BLOG
H
Help Net Security

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Recover a deleted Deployment from a Retain-policy volume ...
The Cyber Sidekick · 2026-06-21 · via DEV Community

The Cyber Sidekick

The Retained Volume

Someone deleted a database deployment by accident. The good news: the data is still on disk. In the next few minutes you'll reconnect it the way the CKA exam expects.

🎥 Watch the video: https://www.youtube.com/watch?v=0GvawTDSyiU

This is a CKA Storage walkthrough. Every command below is real output from a live cluster, and you can reproduce the whole thing yourself (scripts at the end).

The scenario

A MariaDB deployment in the mariadb namespace was deleted. Its volume uses the Retain reclaim policy, so the data survived. Your task: create a claim for that volume, point the deployment at it, apply, and verify the pod is running with no restarts.

  • MariaDB Deployment in namespace mariadb was deleted
  • Its PV uses Retain, so the data is still there
  • Create a PVC bound to that PV
  • Re-wire the Deployment, apply, and verify

How storage binding works

Storage in Kubernetes is a chain. A Deployment mounts a persistent volume claim. The claim binds to a persistent volume, which is the actual disk. Delete the claim and the deployment, and with Retain the volume keeps the data, waiting for a new claim to pick it back up.

Reproduce symptom

First, confirm the symptom. The mariadb namespace has no deployment and no pods. The workload is simply gone.

$ kubectl -n mariadb get deploy,pods
No resources found in mariadb namespace.

Confirm the data survived

Now the good news. The persistent volume still exists, its reclaim policy is Retain, and it is Available. That Retain policy is why your data outlived the deployment.

$ kubectl get pv mariadb
NAME      CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM   STORAGECLASS   VOLUMEATTRIBUTESCLASS   REASON   AGE
mariadb   250Mi      RWO            Retain           Available                          <unset>                          10h

Create the claim

Create a file, mariadb-pvc.yaml. Two details matter: an empty storage class name, so Kubernetes binds the existing volume instead of provisioning a new one, and a volume name that points straight at the PV. Apply it, and it binds immediately.

$ cat mariadb-pvc.yaml
...
metadata:
  name: mariadb
  namespace: mariadb
spec:
  accessModes:
    - ReadWriteOnce
  # Must match the PV: empty class (static, no dynamic provisioning) and an explicit
  # volumeName so it binds to the retained "mariadb" PV rather than a new one.
  storageClassName: ""
  volumeName: mariadb
  resources:
    requests:
      storage: 250Mi

$ kubectl apply -f mariadb-pvc.yaml
persistentvolumeclaim/mariadb created

$ kubectl -n mariadb get pvc
NAME      STATUS   VOLUME    CAPACITY   ACCESS MODES   STORAGECLASS   VOLUMEATTRIBUTESCLASS   AGE
mariadb   Bound    mariadb   250Mi      RWO                           <unset>                 1s

Verify

Apply the wired deployment, and prove it. The pod is Running with zero restarts, on top of the original data. The deployment is recovered.

$ kubectl apply -f mariadb-deployment.yaml
deployment.apps/mariadb created

$ kubectl -n mariadb get pods
NAME                       READY   STATUS    RESTARTS   AGE
mariadb-68cd856df4-jx6mm   1/1     Running   0          0s

Exam tips

A few traps to remember. Use an empty storage class name to force a static bind, or the cluster's default provisioner will hand you a brand new empty volume. After you delete a claim, a Retain volume goes to Released, not Available; clear its claimRef to make it bindable again. And always confirm the claim is Bound before you expect the pod to start.

  • storageClassName "" = static bind (avoid the default provisioner)
  • volumeName targets a specific PV
  • Retain PV goes Released after PVC delete; clear claimRef to rebind
  • Confirm PVC is Bound before expecting the pod to run

Recap

  • Retain preserves data past the claim's life
  • Re-bind: PVC with empty class + volumeName
  • Wire the Deployment, then verify Bound + Running
  • Subscribe + dev.to writeup

Reproduce this yourself

The entire scenario is scripted on a throwaway kind cluster:

git clone <repo> && cd learning/scenarios/scenario2-retained-pv-recovery
./setup.sh        # creates the cluster AND arms it (namespace + retained PV, deployment gone)
# solve it by hand, or:
./solution.sh     # apply the answer key and verify recovery


If this helped, subscribe to The Cyber SideKick on YouTube for more CKA drills, and grab the newsletter at https://thecybersidekick.beehiiv.com.