Last active
March 1, 2022 10:04
-
-
Save khaled/c2109f516c3775db0bdafa9e574cec52 to your computer and use it in GitHub Desktop.
creates a temporary pod that can be use to inspect the contents of a kubernetes pvc. the pvc is mounted in the /data directory.
This file contains 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 | |
# | |
# usage: ./volumeInspector.sh <pvc-name> <namespace> | |
# | |
# creates a temporary pod that can be use to inspect the contents | |
# of a pvc. the pvc is mounted in the /data directory. | |
# | |
# | |
# get pvcs in a namespace by running: | |
# kubectl get pvc -n <namespace> | |
# | |
read -r -d '' config <<-EOT | |
{ | |
"kind": "Pod", | |
"apiVersion": "v1", | |
"spec": { | |
"volumes": [ | |
{ | |
"name": "vol", | |
"persistentVolumeClaim": { | |
"claimName": "$1" | |
} | |
} | |
], | |
"containers": [ | |
{ | |
"name": "inspector", | |
"image": "busybox", | |
"stdin": true, | |
"stdinOnce": true, | |
"tty": true, | |
"volumeMounts": [ | |
{ | |
"mountPath": "/data", | |
"name": "vol" | |
} | |
] | |
} | |
] | |
} | |
} | |
EOT | |
kubectl run -it --rm --image=busybox --restart=Never --overrides="$config" -n $2 -- bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome, thanks!