Last active
December 13, 2025 14:44
-
-
Save vebutton/e86221f3c29eea4517a7a54223a8a1f5 to your computer and use it in GitHub Desktop.
patch-pvc-annotation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cleanpvc() { | |
| if [ -z "$1" ]; then | |
| echo "Error: Please provide a Persistent Volume Claim (PVC) name." | |
| echo "Usage: cleanpvc <pvc-name>" | |
| return 1 | |
| fi | |
| local PVC_NAME="$1" | |
| echo "Attempting to remove system annotations from PVC: ${PVC_NAME}..." | |
| oc patch pvc "$PVC_NAME" --type='json' -p='[{"op": "remove", "path": "/metadata/annotations/pv.kubernetes.io~1bind-completed"},{"op": "remove", "path": "/metadata/annotations/pv.kubernetes.io~1bound-by-controller"}]' | |
| if [ $? -eq 0 ]; then | |
| echo "Success: PVC '${PVC_NAME}' annotations removed." | |
| else | |
| echo "Error: Failed to patch PVC. Check if the name is correct or if the PVC exists." | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment