Skip to content

Instantly share code, notes, and snippets.

@andromedarabbit
Created July 29, 2018 14:16
Show Gist options
  • Select an option

  • Save andromedarabbit/e3e6adfb09583a6a00d5a1765a3977cb to your computer and use it in GitHub Desktop.

Select an option

Save andromedarabbit/e3e6adfb09583a6a00d5a1765a3977cb to your computer and use it in GitHub Desktop.

Revisions

  1. andromedarabbit created this gist Jul 29, 2018.
    12 changes: 12 additions & 0 deletions set-reclaimpolicy-to-retain.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #!/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