Created
February 16, 2024 09:01
-
-
Save arrase/05ba0677f02b074a7df52902ccdb7b77 to your computer and use it in GitHub Desktop.
Run pod and mount volume from command line
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 | |
PVC=$(kubectl get pvc -o jsonpath="{.items[0].metadata.name}" 2> /dev/null) | |
[ -z "$PVC" ] && echo "No encuentro ninguna PVC en este namespace" && exit 1 | |
kubectl run ubuntu --image ubuntu --rm -ti --restart=Never --overrides=" | |
{ | |
\"spec\": { | |
\"containers\": [ | |
{ | |
\"stdin\": true, | |
\"tty\": true, | |
\"args\": [ \"bash\" ], | |
\"name\": \"ubuntu\", | |
\"image\": \"ubuntu\", | |
\"volumeMounts\": [ | |
{ | |
\"mountPath\": \"/tmp/filestore\", | |
\"name\": \"store\" | |
} | |
] | |
} | |
], | |
\"volumes\": [ | |
{ | |
\"name\": \"store\", | |
\"persistentVolumeClaim\": { | |
\"claimName\":\"$PVC\" | |
} | |
} | |
] | |
} | |
} | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment