Skip to content

Instantly share code, notes, and snippets.

@vebutton
Last active December 13, 2025 14:44
Show Gist options
  • Select an option

  • Save vebutton/e86221f3c29eea4517a7a54223a8a1f5 to your computer and use it in GitHub Desktop.

Select an option

Save vebutton/e86221f3c29eea4517a7a54223a8a1f5 to your computer and use it in GitHub Desktop.
patch-pvc-annotation
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