Last active
July 11, 2023 03:22
-
-
Save TJM/c65292987937b387741c0b529f5aa1ac to your computer and use it in GitHub Desktop.
K8s-Storage-shell - Connect to PVC with interactive shell
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 | |
# | |
# Start a debug-storage container mounting a specific volume (pvc) | |
# | |
IMAGE='centos:7' | |
if [ $# == 1 ]; then | |
PVC=$1 | |
else | |
>&2 echo "ERROR: Please provide PVC to attach to" | |
exit 1 | |
fi | |
kubectl run -it --rm=true --tty k8s-storage-shell --overrides=' | |
{ | |
"apiVersion": "v1", | |
"spec": { | |
"containers": [ | |
{ | |
"name": "shell", | |
"image": "'$IMAGE'", | |
"args": [ | |
"bash" | |
], | |
"stdin": true, | |
"stdinOnce": true, | |
"tty": true, | |
"volumeMounts": [ | |
{ | |
"mountPath": "/data", | |
"name": "debug-storage" | |
} | |
] | |
} | |
], | |
"volumes": [ | |
{ | |
"name": "debug-storage", | |
"persistentVolumeClaim": { | |
"claimName": "'$PVC'" | |
} | |
} | |
] | |
} | |
} | |
' --restart=Never --image ${IMAGE} -- bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment