|
| 1 | +# Rclone |
| 2 | + |
| 3 | +For this template we are using the official [rclone docker image](https://hub.docker.com/r/rclone/rclone) in docker hub. |
| 4 | + |
| 5 | +In order to install this version of the template into a namespace do: |
| 6 | + |
| 7 | +```bash |
| 8 | +$ oc create -f rclone.yaml |
| 9 | +template.template.openshift.io/rclone created |
| 10 | +``` |
| 11 | + |
| 12 | +Then use the template from the web interface, or from the command line: |
| 13 | + |
| 14 | +```bash |
| 15 | +$ oc process rclone \ |
| 16 | + ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \ |
| 17 | + SECRET_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \ |
| 18 | + PVC=existing_pvc \ |
| 19 | + BUCKET_DIR=existing_bucket/existing/path |
| 20 | +``` |
| 21 | + |
| 22 | +## Command line tests |
| 23 | + |
| 24 | +In `rclone.conf`, replace the credentials (`${ACCESSKEY}` and `${SECRETKEY}`) and the endpoint (`${S3HOST}`) with their appropriate values. |
| 25 | + |
| 26 | +```bash |
| 27 | +$ cp rclone.conf ~/.config/rclone/ |
| 28 | +$ docker run --rm \ |
| 29 | + --volume ~/.config/rclone:/config/rclone \ |
| 30 | + --volume ~/data:/data:shared \ |
| 31 | + --user $(id -u):$(id -g) \ |
| 32 | + --volume /etc/passwd:/etc/passwd:ro --volume /etc/group:/etc/group:ro \ |
| 33 | + --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined \ |
| 34 | + rclone/rclone \ |
| 35 | + listremotes |
| 36 | +``` |
| 37 | + |
| 38 | +Should output: |
| 39 | + |
| 40 | +```bash |
| 41 | +default: |
| 42 | +``` |
| 43 | + |
| 44 | +Then, in order to list the buckets in the project: |
| 45 | + |
| 46 | +```bash |
| 47 | +$ docker run --rm \ |
| 48 | + --volume ~/.config/rclone:/config/rclone \ |
| 49 | + --volume ~/data:/data:shared \ |
| 50 | + --user $(id -u):$(id -g) \ |
| 51 | + --volume /etc/passwd:/etc/passwd:ro --volume /etc/group:/etc/group:ro \ |
| 52 | + --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined \ |
| 53 | + rclone/rclone \ |
| 54 | + lsd default: |
| 55 | +``` |
| 56 | + |
| 57 | +With this information, it is possible to mount a remote S3 remote bucket into a local folder: |
| 58 | + |
| 59 | +```bash |
| 60 | +$ sudo chcon -Rt svirt_sandbox_file_t ~/data |
| 61 | +$ sudo docker run --rm \ |
| 62 | + --volume ~/.config/rclone:/config/rclone \ |
| 63 | + --volume ~/data:/data:shared \ |
| 64 | + --device /dev/fuse --cap-add SYS_ADMIN \ |
| 65 | + rclone/rclone mount default:28022020-gonzalez /data/home |
| 66 | +``` |
| 67 | + |
| 68 | +Meanwhile the docker command is running, you can read the files in the bucket from a different terminal (as root): |
| 69 | + |
| 70 | +```bash |
| 71 | +sudo ls ~/data |
| 72 | +``` |
| 73 | + |
| 74 | +## Obtain the S3 credentials |
| 75 | + |
| 76 | +We will use the command line to obtain the credentials. First install the command line client: |
| 77 | + |
| 78 | +```bash |
| 79 | +pip install python-openstackclient |
| 80 | +``` |
| 81 | + |
| 82 | +Then go to [Access & Security](https://pouta.csc.fi/dashboard/project/access_and_security/), download the OpenStack RC File v2.0, and source it: |
| 83 | + |
| 84 | +```bash |
| 85 | +$ source ~/Downloads/project_XXXXXXX-openrc.sh |
| 86 | +Please enter your OpenStack Password for project project_2001316 as user <USER>: |
| 87 | + |
| 88 | +``` |
| 89 | + |
| 90 | +Finally you can list the credentials: |
| 91 | + |
| 92 | +```bash |
| 93 | +openstack ec2 credentials list -f yaml |
| 94 | +``` |
| 95 | + |
| 96 | +We are interested in `Access:` and `Secret:`. |
0 commit comments