Created
March 6, 2019 12:39
-
-
Save Pamir/ac235b0af0e464ed11748bbfc6056e88 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
dump_pvinfo(){ | |
namespace=$1 | |
for pvc in $(kubectl get pvc -o=jsonpath="{.items[*].metadata.name}" -n $namespace); do | |
echo " " $pvc | |
pv=$(kubectl get pvc -o=jsonpath="{.spec.volumeName}" -n $namespace $pvc) | |
echo " " $pv | |
pdName=$(kubectl get pv -o=jsonpath="{.spec.gcePersistentDisk.pdName}" -n $namespace $pv) | |
echo " " $pdName | |
gcloud compute disks list --filter="name=('$pdName')" | tail -n +2 | while read DISK_NAME ZONE c3 c4; do | |
SNAPSHOTNAME=$DISK_NAME-$(date -j -v-60d "+%Y-%m-%d") | |
SNAPNAME=$(echo $SNAPSHOTNAME | cut -c1-60) | |
echo $SNAPNAME | |
gcloud compute disks snapshot $DISK_NAME --snapshot-names $SNAPNAME --zone $ZONE | |
done | |
done; | |
} | |
for namespace in $(kubens); do | |
echo $namespace | |
dump_pvinfo $namespace | |
done; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
public