Skip to content

Instantly share code, notes, and snippets.

@arrase
Created February 16, 2024 09:01
Show Gist options
  • Save arrase/05ba0677f02b074a7df52902ccdb7b77 to your computer and use it in GitHub Desktop.
Save arrase/05ba0677f02b074a7df52902ccdb7b77 to your computer and use it in GitHub Desktop.
Run pod and mount volume from command line
#!/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