Skip to content

Instantly share code, notes, and snippets.

@caruccio
Created October 4, 2019 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caruccio/feabe0e4289d8e2199db26a2cd240593 to your computer and use it in GitHub Desktop.
Save caruccio/feabe0e4289d8e2199db26a2cd240593 to your computer and use it in GitHub Desktop.
Generates an rsync pod to copy between two PVCs
#!/bin/bash
if [ $# -lt 3 ]; then
echo "Usage: $0 pod-name-suffix source-pvc-name destination-pvc-name [rsync options...]"
exit 1
fi
POD_SUFFIX=${1}
PVC_FROM=${2}
PVC_TO=${3}
shift 3
RSYNC_OPTIONS="$@"
cat <<EOF
apiVersion: v1
kind: Pod
metadata:
labels:
run: rsync-${POD_SUFFIX}
name: rsync-${POD_SUFFIX}
spec:
containers:
- command:
- rsync
${RSYNC_OPTIONS}
- /tmp/pvc-from
- /tmp/pvc-to
image: centos:7
imagePullPolicy: IfNotPresent
name: shell
tty: true
stdin: true
resources:
limits:
cpu: 100m
memory: 64Mi
requests:
cpu: 10m
memory: 32Mi
volumeMounts:
- mountPath: /tmp/pvc-from
name: pvc-from
readOnly: true
- mountPath: /tmp/pvc-to
name: pvc-to
readOnly: true
volumes:
- name: pvc-from
persistentVolumeClaim:
claimName: $PVC_FROM
readOnly: true
- name: pvc-to
persistentVolumeClaim:
claimName: $PVC_TO
readOnly: false
EOF
@caruccio
Copy link
Author

caruccio commented Oct 4, 2019

Never tested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment