{"id":41463,"date":"2026-11-26T22:04:47","date_gmt":"2026-11-26T22:04:47","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=41463"},"modified":"2026-11-26T22:04:47","modified_gmt":"2026-11-26T22:04:47","slug":"kubectl-persistent-volumes-pv-persistentvolumeclaim-pvc","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/kubectl-persistent-volumes-pv-persistentvolumeclaim-pvc\/","title":{"rendered":"Kubectl: Persistent Volumes PV &amp; PersistentVolumeClaim PVC"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">To turn an existing PersistentVolumeClaim (PVC) into a YAML manifest you can deploy again, run <code>kubectl get pvc &lt;name&gt; -o yaml<\/code> and remove the fields the cluster generates: <code>status<\/code>, <code>uid<\/code>, <code>resourceVersion<\/code>, <code>creationTimestamp<\/code>, binding annotations and, in some cases, <code>spec.volumeName<\/code>. The commands above are a starting point, but the grep version produces invalid YAML. This page explains why, gives corrected commands using yq, jq and kubectl-neat, and covers how PVs and PVCs bind so the restored claim actually reaches the Bound state.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/5b2819048272debff37a4c4103eea602.js\"><\/script>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">PV and PVC in brief<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A <strong>PersistentVolume (PV)<\/strong> is a piece of storage in the cluster. An administrator creates it by hand, or a StorageClass provisioner creates it on demand. A <strong>PersistentVolumeClaim (PVC)<\/strong> is a namespaced request for storage that a Pod mounts. The control plane binds each PVC to exactly one PV, and that binding is recorded on both objects. This matters when you export and re-create a PVC.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Field<\/th><th>Object<\/th><th>What it means for export<\/th><\/tr><\/thead><tbody><tr><td><code>spec.volumeName<\/code><\/td><td>PVC<\/td><td>Name of the PV the claim is bound to. Keep it to rebind the same PV. Remove it to get a new volume.<\/td><\/tr><tr><td><code>spec.claimRef<\/code><\/td><td>PV<\/td><td>Points to the PVC by name, namespace and <strong>uid<\/strong>. A re-created PVC has a new uid, so a stale claimRef blocks binding.<\/td><\/tr><tr><td><code>spec.storageClassName<\/code><\/td><td>PVC and PV<\/td><td>Must exist in the target cluster, or dynamic provisioning fails.<\/td><\/tr><tr><td><code>persistentVolumeReclaimPolicy<\/code><\/td><td>PV<\/td><td><code>Delete<\/code> removes the storage when the PVC is deleted. <code>Retain<\/code> keeps it.<\/td><\/tr><tr><td><code>status<\/code><\/td><td>Both<\/td><td>Runtime state written by the cluster. Never include it in a manifest.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Why the grep one-liner produces broken YAML<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>grep -v<\/code> deletes single lines. It does not understand YAML structure. It removes the <code>status:<\/code> line but leaves the indented lines under it. Here is typical raw output for a dynamically provisioned claim:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">apiVersion: v1\n<span class=\"hljs-attr\">kind<\/span>: PersistentVolumeClaim\n<span class=\"hljs-attr\">metadata<\/span>:\n  annotations:\n    pv.kubernetes.io\/bind-completed: <span class=\"hljs-string\">\"yes\"<\/span>\n    pv.kubernetes.io\/bound-by-controller: <span class=\"hljs-string\">\"yes\"<\/span>\n    volume.kubernetes.io\/storage-provisioner: ebs.csi.aws.com\n  <span class=\"hljs-attr\">creationTimestamp<\/span>: <span class=\"hljs-string\">\"2023-05-10T08:12:44Z\"<\/span>\n  <span class=\"hljs-attr\">finalizers<\/span>:\n  - kubernetes.io\/pvc-protection\n  <span class=\"hljs-attr\">name<\/span>: grafana-pod\n  <span class=\"hljs-attr\">namespace<\/span>: management\n  <span class=\"hljs-attr\">resourceVersion<\/span>: <span class=\"hljs-string\">\"184233\"<\/span>\n  <span class=\"hljs-attr\">uid<\/span>: <span class=\"hljs-number\">7<\/span>c1e2f4a<span class=\"hljs-number\">-0<\/span>d6b<span class=\"hljs-number\">-4<\/span>c55<span class=\"hljs-number\">-9<\/span>a51<span class=\"hljs-number\">-3<\/span>f0e1b2c9d10\n<span class=\"hljs-attr\">spec<\/span>:\n  accessModes:\n  - ReadWriteOnce\n  <span class=\"hljs-attr\">resources<\/span>:\n    requests:\n      storage: <span class=\"hljs-number\">10<\/span>Gi\n  <span class=\"hljs-attr\">storageClassName<\/span>: gp3\n  <span class=\"hljs-attr\">volumeMode<\/span>: Filesystem\n  <span class=\"hljs-attr\">volumeName<\/span>: pvc<span class=\"hljs-number\">-7<\/span>c1e2f4a<span class=\"hljs-number\">-0<\/span>d6b<span class=\"hljs-number\">-4<\/span>c55<span class=\"hljs-number\">-9<\/span>a51<span class=\"hljs-number\">-3<\/span>f0e1b2c9d10\n<span class=\"hljs-attr\">status<\/span>:\n  accessModes:\n  - ReadWriteOnce\n  <span class=\"hljs-attr\">capacity<\/span>:\n    storage: <span class=\"hljs-number\">10<\/span>Gi\n  <span class=\"hljs-attr\">phase<\/span>: Bound<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Once the <code>status:<\/code> line is gone, <code>accessModes<\/code>, <code>capacity<\/code> and <code>phase<\/code> move up into <code>spec<\/code>. That gives a duplicate <code>accessModes<\/code> key and unknown fields <code>spec.capacity<\/code> and <code>spec.phase<\/code>. Current kubectl validates strictly by default, so <code>kubectl apply<\/code> rejects the file with a duplicate-key or unknown-field error. Older clients might accept it and silently drop fields. The grep version also leaves the binding annotations and <code>volumeName<\/code> in place, so the claim can sit in <code>Pending<\/code> even when the file is accepted.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> <code>selfLink<\/code> is no longer populated by current Kubernetes versions, and kubectl hides <code>managedFields<\/code> by default. Deleting them is harmless, but they are not the real problem. The old <code>kubectl get --export<\/code> flag was removed in Kubernetes 1.18, which is why these cleanup pipelines exist.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Corrected export commands<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Option 1: yq (mikefarah yq v4).<\/strong> It deletes whole YAML nodes, children included. In v4 the <code>eval<\/code> subcommand is the default, so <code>yq &#039;...&#039;<\/code> and <code>yq eval &#039;...&#039; -<\/code> do the same thing. The Python <code>yq<\/code> package uses jq syntax and will not run this expression.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">kubectl <span class=\"hljs-keyword\">get<\/span> pvc grafana-pod -n management -o yaml | yq 'del(\n    .status,\n    .metadata.creationTimestamp,\n    .metadata.resourceVersion,\n    .metadata.uid,\n    .metadata.selfLink,\n    .metadata.managedFields,\n    .metadata.annotations&#91;\"pv.kubernetes.io\/bind-completed\"],\n    .metadata.annotations&#91;\"pv.kubernetes.io\/bound-by-controller\"],\n    .metadata.annotations&#91;\"volume.kubernetes.io\/storage-provisioner\"],\n    .metadata.annotations&#91;\"volume.beta.kubernetes.io\/storage-provisioner\"],\n    .metadata.annotations&#91;\"kubectl.kubernetes.io\/last-applied-configuration\"]\n  )' &gt; deployable-pvc.yaml<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Option 2: jq.<\/strong> Use it when yq is not installed. <code>kubectl apply<\/code> accepts JSON files as well as YAML.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">kubectl <span class=\"hljs-keyword\">get<\/span> pvc grafana-pod -n management -o json | jq 'del(\n    .status,\n    .metadata.creationTimestamp,\n    .metadata.resourceVersion,\n    .metadata.uid,\n    .metadata.managedFields,\n    .metadata.annotations&#91;\"pv.kubernetes.io\/bind-completed\"],\n    .metadata.annotations&#91;\"pv.kubernetes.io\/bound-by-controller\"],\n    .metadata.annotations&#91;\"kubectl.kubernetes.io\/last-applied-configuration\"]\n  )' &gt; deployable-pvc.json<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Option 3: the kubectl-neat plugin.<\/strong> It removes common cluster-generated fields for you. Install it with krew, then check the output by eye before you apply it.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">kubectl krew install neat\nkubectl <span class=\"hljs-keyword\">get<\/span> pvc grafana-pod -n management -o yaml | kubectl neat &gt; deployable-pvc.yaml<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">To export every PVC in a namespace at once, run the same delete expression against the <code>List<\/code> object. Here is the yq version:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">kubectl <span class=\"hljs-keyword\">get<\/span> pvc -n management -o yaml | yq 'del(\n    .items&#91;].status,\n    .items&#91;].metadata.creationTimestamp,\n    .items&#91;].metadata.resourceVersion,\n    .items&#91;].metadata.uid,\n    .items&#91;].metadata.annotations&#91;\"pv.kubernetes.io\/bind-completed\"],\n    .items&#91;].metadata.annotations&#91;\"pv.kubernetes.io\/bound-by-controller\"]\n  )' &gt; all-pvcs.yaml<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Same cluster or a new cluster: decide on volumeName<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A clean manifest still needs one decision: should the claim attach to the <strong>existing<\/strong> volume or get a <strong>new<\/strong> one?<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>New cluster or fresh, empty volume:<\/strong> delete <code>spec.volumeName<\/code> too, for example by adding <code>.spec.volumeName<\/code> to the <code>del(...)<\/code> list. The StorageClass then provisions a new PV. Make sure the <code>storageClassName<\/code> exists in the target cluster (<code>kubectl get storageclass<\/code>).<\/li>\n\n\n<li><strong>Same cluster, keep the data:<\/strong> keep <code>spec.volumeName<\/code>. The PV must use the <code>Retain<\/code> reclaim policy, and its stale <code>claimRef<\/code> must be cleared (see the next section). If the reclaim policy was <code>Delete<\/code>, the storage was removed when the old PVC was deleted.<\/li>\n\n\n<li><strong>Moving data between clusters:<\/strong> exporting the manifest does not copy any data. Use a backup tool or CSI volume snapshots, or point a static PV at the same cloud disk.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Here is a cleaned manifest for the same-cluster case:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">apiVersion: v1\nkind: PersistentVolumeClaim\nmetadata:\n  name: grafana-pod\n  namespace: management\n  finalizers:\n  - kubernetes.io\/pvc-protection\nspec:\n  accessModes:\n  - ReadWriteOnce\n  resources:\n    requests:\n      storage: 10Gi\n  storageClassName: gp3\n  volumeMode: Filesystem\n  volumeName: pvc-7c1e2f4a-0d6b-4c55-9a51-3f0e1b2c9d10<\/code><\/span><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Keeping the <code>kubernetes.io\/pvc-protection<\/code> finalizer is fine, because the cluster adds it anyway. Do not strip finalizers from live objects to force a deletion. That can orphan storage that is still in use.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Rebinding a retained PV<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After you delete a PVC, a PV with the <code>Retain<\/code> policy moves to <code>Released<\/code>. It stays reserved for the old claim&#039;s uid and will not bind to the re-created PVC. Protect the PV first, then clear the reference:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Before deleting the PVC, make sure the PV will survive<\/span>\nkubectl patch pv pvc<span class=\"hljs-number\">-7<\/span>c1e2f4a<span class=\"hljs-number\">-0<\/span>d6b<span class=\"hljs-number\">-4<\/span>c55<span class=\"hljs-number\">-9<\/span>a51<span class=\"hljs-number\">-3<\/span>f0e1b2c9d10 \\\n  -p <span class=\"hljs-string\">'{\"spec\":{\"persistentVolumeReclaimPolicy\":\"Retain\"}}'<\/span>\n\n<span class=\"hljs-comment\"># After the PVC is deleted, the PV shows STATUS Released<\/span>\nkubectl get pv pvc<span class=\"hljs-number\">-7<\/span>c1e2f4a<span class=\"hljs-number\">-0<\/span>d6b<span class=\"hljs-number\">-4<\/span>c55<span class=\"hljs-number\">-9<\/span>a51<span class=\"hljs-number\">-3<\/span>f0e1b2c9d10\n\n<span class=\"hljs-comment\"># Remove the stale claimRef so the PV becomes Available<\/span>\nkubectl patch pv pvc<span class=\"hljs-number\">-7<\/span>c1e2f4a<span class=\"hljs-number\">-0<\/span>d6b<span class=\"hljs-number\">-4<\/span>c55<span class=\"hljs-number\">-9<\/span>a51<span class=\"hljs-number\">-3<\/span>f0e1b2c9d10 \\\n  --type json -p <span class=\"hljs-string\">'&#91;{\"op\":\"remove\",\"path\":\"\/spec\/claimRef\"}]'<\/span>\n\n<span class=\"hljs-comment\"># Re-create the claim<\/span>\nkubectl apply -f deployable-pvc.yaml<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">If you also want a manifest for the PV itself, export it the same way and remove <code>status<\/code>, <code>metadata.uid<\/code>, <code>metadata.resourceVersion<\/code>, <code>metadata.creationTimestamp<\/code> and <code>spec.claimRef<\/code>. If you want to pre-bind it to the new claim, keep only <code>name<\/code> and <code>namespace<\/code> under <code>claimRef<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Validate and apply<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Check the file locally: <code>kubectl apply --dry-run=client -f deployable-pvc.yaml<\/code>.<\/li>\n\n\n<li>Validate against the API server, including strict field checks: <code>kubectl apply --dry-run=server -f deployable-pvc.yaml<\/code>. Expected output: <code>persistentvolumeclaim\/grafana-pod created (server dry run)<\/code>.<\/li>\n\n\n<li>Apply it: <code>kubectl apply -f deployable-pvc.yaml<\/code>.<\/li>\n\n\n<li>Watch the binding: <code>kubectl get pvc grafana-pod -n management -w<\/code>. <code>STATUS<\/code> should change to <code>Bound<\/code>. With a <code>WaitForFirstConsumer<\/code> StorageClass, it stays <code>Pending<\/code> until a Pod uses the claim. That is expected.<\/li>\n\n\n<li>If the claim stays Pending, run <code>kubectl describe pvc grafana-pod -n management<\/code> and read the Events section.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Common errors and fixes<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Symptom<\/th><th>Cause<\/th><th>Fix<\/th><\/tr><\/thead><tbody><tr><td><code>unknown field &quot;spec.capacity&quot;<\/code> or a duplicate <code>accessModes<\/code> key<\/td><td>The grep one-liner left <code>status<\/code> children in the file<\/td><td>Use yq, jq or kubectl-neat to delete the whole <code>status<\/code> node<\/td><\/tr><tr><td><code>the object has been modified<\/code> or a resourceVersion conflict<\/td><td><code>metadata.resourceVersion<\/code> was left in the file<\/td><td>Delete <code>resourceVersion<\/code> and <code>uid<\/code><\/td><\/tr><tr><td><code>spec is immutable after creation except resources.requests...<\/code><\/td><td>You applied changed spec fields to a PVC that already exists<\/td><td>Delete and re-create the PVC. Only storage size can grow in place, and only if the StorageClass sets <code>allowVolumeExpansion: true<\/code><\/td><\/tr><tr><td>PVC stuck in <code>Pending<\/code> with <code>volumeName<\/code> set<\/td><td>The PV is Released with a stale <code>claimRef<\/code>, or it does not exist in this cluster<\/td><td>Clear the PV&#039;s <code>claimRef<\/code>, or remove <code>volumeName<\/code> to provision a new volume<\/td><\/tr><tr><td><code>storageclass.storage.k8s.io &quot;gp3&quot; not found<\/code><\/td><td>The target cluster uses different StorageClass names<\/td><td>Change <code>storageClassName<\/code> to one listed by <code>kubectl get sc<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Everyday PV and PVC commands<\/h2>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">kubectl get pv                                   <span class=\"hljs-comment\"># cluster-wide volumes, status, claim, reclaim policy<\/span>\nkubectl get pvc -A                               <span class=\"hljs-comment\"># claims in all namespaces<\/span>\nkubectl describe pvc grafana-pod -n management   <span class=\"hljs-comment\"># events, bound volume, mounted-by pods<\/span>\nkubectl get storageclass                         <span class=\"hljs-comment\"># provisioners, default class, expansion support<\/span>\nkubectl get pvc grafana-pod -n management \\\n  -o jsonpath=<span class=\"hljs-string\">'{.spec.volumeName}{\"\\n\"}'<\/span>          <span class=\"hljs-comment\"># which PV backs this claim<\/span>\nkubectl patch pvc grafana-pod -n management \\\n  -p <span class=\"hljs-string\">'{\"spec\":{\"resources\":{\"requests\":{\"storage\":\"20Gi\"}}}}'<\/span>   <span class=\"hljs-comment\"># expand, if allowed<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">For workloads that use these claims, and for other kubectl walkthroughs, see the <a href=\"https:\/\/www.devopsschool.com\/blog\/category\/containers-kubernetes\/kubernetes\/\">Kubernetes tutorials<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">How do I export a Kubernetes PVC to YAML?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run <code>kubectl get pvc &lt;name&gt; -n &lt;namespace&gt; -o yaml<\/code>, then remove <code>status<\/code>, <code>uid<\/code>, <code>resourceVersion<\/code>, <code>creationTimestamp<\/code> and the binding annotations with yq, jq or the kubectl-neat plugin. Plain <code>grep -v<\/code> is unsafe because it leaves the nested lines of <code>status<\/code> behind.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why does kubectl get &#8211;export not work anymore?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>--export<\/code> flag was deprecated and then removed in Kubernetes 1.18. Use <code>-o yaml<\/code> together with a cleanup tool such as yq or kubectl-neat.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why is my re-created PVC stuck in Pending?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The usual causes are a <code>spec.volumeName<\/code> pointing to a PV that is Released with a stale <code>claimRef<\/code>, a PV that does not exist in the cluster, a missing StorageClass, or a <code>WaitForFirstConsumer<\/code> StorageClass that is waiting for a Pod. <code>kubectl describe pvc<\/code> shows which one applies.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Does exporting a PVC manifest back up the data?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. The manifest only describes the storage request. To protect the data, use a backup tool or CSI volume snapshots, and set the PV reclaim policy to <code>Retain<\/code> before you delete the claim.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can I edit a PVC after it is created?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Most of the PVC spec cannot be changed after creation. The main exception is increasing <code>resources.requests.storage<\/code> when the StorageClass allows volume expansion. For any other change, re-create the claim.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related tutorials<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/category\/containers-kubernetes\/kubernetes\/\">More Kubernetes tutorials<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/troubleshooting-guide-to-resolving-500-errors-in-kubernetes-production-environments\/\">Troubleshooting Guide to Resolving 500 Errors in Kubernetes Production Environments<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/kubernetes-administrator-role-blueprint-responsibilities-skills-kpis-and-career-path\/\">Kubernetes Administrator: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>To turn an existing PersistentVolumeClaim (PVC) into a YAML manifest you can deploy again, run kubectl get pvc &lt;name&gt; -o yaml and remove the fields the cluster&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[4859],"tags":[4945,26179],"class_list":["post-41463","post","type-post","status-publish","format-standard","hentry","category-kubernetes","tag-kubectl","tag-kubernetes-persistent-volumes"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/41463","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=41463"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/41463\/revisions"}],"predecessor-version":[{"id":80298,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/41463\/revisions\/80298"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=41463"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=41463"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=41463"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}