Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement