Created
August 8, 2019 18:36
-
-
Save dleehr/c8ba6ad1303d47bfa434b85f53ce3f28 to your computer and use it in GitHub Desktop.
Script for one-off pod to mount a PVC
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 | |
set -eo pipefail | |
NAMESPACE=$1 | |
PVC=$2 | |
if [ "$#" -ne 2 ]; then | |
echo "Usage: $0 <namespace> <pvc-name>" | |
exit 1 | |
fi | |
kubectl run --rm -n $NAMESPACE --attach=true -i attach-${PVC} --overrides=' | |
{ | |
"spec": { | |
"containers": [ | |
{ | |
"name": "attach", | |
"image": "debian:stretch-slim", | |
"workingDir": "/attached", | |
"command": ["bash"], | |
"stdin": true, | |
"stdinOnce": true, | |
"tty": true, | |
"volumeMounts": [ | |
{ "mountPath": "/attached", "name": "attached", "readOnly": false } | |
] | |
} | |
], | |
"restartPolicy": "Never", | |
"volumes": [ | |
{ "name": "attached", "persistentVolumeClaim": {"claimName": "'${PVC}'" } } | |
] | |
} | |
} | |
' --image=debian:stretch-slim --restart=Never |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment