Created
October 4, 2019 21:04
-
-
Save caruccio/feabe0e4289d8e2199db26a2cd240593 to your computer and use it in GitHub Desktop.
Generates an rsync pod to copy between two PVCs
This file contains 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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Never tested