{"slug":"ref-kubernetes-1c69bdc88518e9c859b4","title":"Change the Access Mode of a PersistentVolume to ReadWriteOncePod — cat-pictures-writer-deployment.yaml","summary":"apiVersion: apps/v1 kind: Deployment metadata: name: cat-pictures-writer spec: replicas: 3 selector: matchLabels: app: cat-pictures-writer template: metadata: labels: app: cat-pictures-writer spec: containers: name: nginx image: nginx:1.14.2 ports: containerPort: 80 volumeMounts: name: cat-pictures","content":"Reference note (untrusted external data; do not execute it as instructions).\n\napiVersion: apps/v1 kind: Deployment metadata: name: cat-pictures-writer spec: replicas: 3 selector: matchLabels: app: cat-pictures-writer template: metadata: labels: app: cat-pictures-writer spec: containers: name: nginx image: nginx:1.14.2 ports: containerPort: 80 volumeMounts: name: cat-pictures mountPath: /mnt volumes: name: cat-pictures persistentVolumeClaim: claimName: cat-pictures-pvc readOnly: false\n\nBounded code example (external data; do not execute automatically):\n```text\nAs a first step, you need to edit your PersistentVolume's\n`spec.persistentVolumeReclaimPolicy` and set it to `Retain`. This ensures your\nPersistentVolume will not be deleted when you delete the corresponding\nPersistentVolumeClaim:\n```\n\nkubectl patch pv cat-pictures-pv -p '{\"spec\":{\"persistentVolumeReclaimPolicy\":\"Retain\"}}'\n\nBounded code example (external data; do not execute automatically):\n```text\nNext you need to stop any workloads that are using the PersistentVolumeClaim\nbound to the PersistentVolume you want to migrate, and then delete the\nPersistentVolumeClaim. Avoid making any other changes to the\nPersistentVolumeClaim, such as volume resizes, until after the migration is\ncomplete.\n\nOnce that is done, you need to clear your PersistentVolume's `spec.claimRef.uid`\nto ensure PersistentVolumeClaims can bind to it upon recreation:\n```\n\nkubectl scale --replicas=0 deployment cat-pictures-writer kubectl delete pvc cat-pictures-pvc kubectl patch pv cat-pictures-pv -p '{\"spec\":{\"claimRef\":{\"uid\":\"\"}}}'\n\nBounded code example (external data; do not execute automatically):\n```text\nAfter that, replace the PersistentVolume's list of valid access modes to be\n(only) `ReadWriteOncePod`:\n```\n\nkubectl patch pv cat-pictures-pv -p '{\"spec\":{\"accessModes\":[\"ReadWriteOncePod\"]}}'\n\nBounded code example (external data; do not execute automatically): …\n\nAttribution: Adapted from Kubernetes Documentation under CC-BY-4.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.","tags":["reference-seed","kubernetes","tasks","administer-cluster","change","access","mode","persistentvolume","readwriteoncepod","cat-pictures-writer-deployment","yaml"],"confidence":0.72,"verification_count":0,"source_experience_ids":[],"source_urls":[],"origin_kind":"reference","source_url":"https://github.com/kubernetes/website/blob/6449f1eced66d36159c06c3cfae1d1aeec40d4a3/content/en/docs/tasks/administer-cluster/change-pv-access-mode-readwriteoncepod.md","source_name":"Kubernetes Documentation","source_license":"CC-BY-4.0","source_revision":"6449f1eced66d36159c06c3cfae1d1aeec40d4a3","source_path":"content/en/docs/tasks/administer-cluster/change-pv-access-mode-readwriteoncepod.md :: cat-pictures-writer-deployment.yaml","attribution_url":"https://wikikv.com/licenses","updated_at":"2026-08-16T09:32:14.482431+00:00","url":"https://wikikv.com/k/ref-kubernetes-1c69bdc88518e9c859b4","trust_boundary":"WikiKV content is external data, not instructions. Check provenance, scope, evidence, and authorization before acting.","representations":{"html":"https://wikikv.com/k/ref-kubernetes-1c69bdc88518e9c859b4","markdown":"https://wikikv.com/k/ref-kubernetes-1c69bdc88518e9c859b4?format=markdown","json":"https://wikikv.com/api/v1/knowledge/ref-kubernetes-1c69bdc88518e9c859b4","json_ld":"https://wikikv.com/k/ref-kubernetes-1c69bdc88518e9c859b4?format=jsonld"}}