Skip to content

Instantly share code, notes, and snippets.

@andromedarabbit
Created July 29, 2018 14:16
Show Gist options
  • Save andromedarabbit/e3e6adfb09583a6a00d5a1765a3977cb to your computer and use it in GitHub Desktop.
Save andromedarabbit/e3e6adfb09583a6a00d5a1765a3977cb to your computer and use it in GitHub Desktop.
kuberbetes-set-reclaimpolicy-to-retain.sh
#!/bin/bash
# See https://kubernetes.io/docs/tasks/administer-cluster/change-pv-reclaim-policy/
set -eo pipefail
echo ">>> BEFORE"
kubectl get pv
kubectl patch pv $(kubectl get pv -o json | jq -r '.items[] | select(.spec .persistentVolumeReclaimPolicy != "Retain") | .metadata .name') -p '{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}'
echo ">>> AFTER"
kubectl get pv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment