Skip to content

Commit c4bb06e

Browse files
committedAug 27, 2020
Add TESK_API_TASKMASTER_STORAGE_CLASS, to be able to change the type of volume created in tasks
0 parents  commit c4bb06e

File tree

3 files changed

+212
-0
lines changed

3 files changed

+212
-0
lines changed
 

‎README.md

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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:`.

‎rclone.conf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[default]
2+
type = s3
3+
provider = Other
4+
env_auth = false
5+
access_key_id = ${ACCESSKEY}
6+
secret_access_key = ${SECRETKEY}
7+
endpoint = ${S3HOST}
8+
location_constraint = regionOne
9+

‎rclone.yaml

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#
2+
# https://hub.docker.com/r/rclone/rclone
3+
#
4+
apiVersion: template.openshift.io/v1
5+
kind: Template
6+
labels:
7+
template: rclone
8+
message: rclone template
9+
metadata:
10+
annotations:
11+
description: Deploys a rclone Cronjob to synchronize a PVC into a S3 bucket/folder
12+
iconClass: "fa fa-cubes"
13+
openshift.io/display-name: rclone
14+
openshift.io/provider-display-name: CSC
15+
name: rclone
16+
objects:
17+
- apiVersion: batch/v1beta1
18+
kind: CronJob
19+
metadata:
20+
labels:
21+
app: rclone
22+
name: rclone
23+
spec:
24+
schedule: ${SCHEDULE}
25+
jobTemplate:
26+
spec:
27+
template:
28+
metadata:
29+
labels:
30+
parent: "rclone"
31+
spec:
32+
containers:
33+
- name: rclone
34+
image: rclone/rclone:1
35+
command: ["rclone", "sync", "-P", "/mnt", "default:${BUCKET_DIR}"]
36+
volumeMounts:
37+
- mountPath: /.rclone.conf
38+
name: rclone-conf
39+
subPath: rclone.conf
40+
- mountPath: /mnt
41+
name: pvc
42+
restartPolicy: OnFailure
43+
volumes:
44+
- name: rclone-conf
45+
secret:
46+
secretName: rclone-conf
47+
defaultMode: 420
48+
items:
49+
- key: rclone.conf
50+
path: rclone.conf
51+
- name: pvc
52+
persistentVolumeClaim:
53+
claimName: ${PVC}
54+
- apiVersion: v1
55+
kind: Secret
56+
metadata:
57+
name: rclone-conf
58+
labels:
59+
app: rclone
60+
type: Opaque
61+
stringData:
62+
"rclone.conf": |-
63+
[default]
64+
type = s3
65+
provider = Other
66+
env_auth = false
67+
access_key_id = ${ACCESS_KEY}
68+
secret_access_key = ${SECRET_KEY}
69+
endpoint = ${S3HOST}
70+
location_constraint = regionOne
71+
72+
parameters:
73+
- name: ACCESS_KEY
74+
required: true
75+
description: Access key
76+
displayName: Access key
77+
from: '[a-zA-Z0-9]{32}'
78+
79+
- name: SECRET_KEY
80+
description: "Secret key"
81+
displayName: Secret key
82+
required: true
83+
from: '[a-zA-Z0-9]{32}'
84+
85+
- name: PVC
86+
description: "Name on the persistent volume claim to synchronize from"
87+
displayName: PersistentVolumeClaim
88+
required: true
89+
90+
- name: BUCKET_DIR
91+
description: "Bucket and directory to synchronize to. The format should be <bucket>/path/path2"
92+
displayName: Bucket and directory
93+
required: true
94+
95+
- name: S3HOST
96+
description: "Host name for the S3 server"
97+
displayName: Host name
98+
required: true
99+
value: "object.pouta.csc.fi"
100+
101+
- name: SCHEDULE
102+
description: >
103+
When to run the cronjob, see https://en.wikipedia.org/wiki/Cron for reference
104+
displayName: Schedule
105+
required: true
106+
value: "30 * * * *"
107+

0 commit comments

Comments
 (0)
Please sign in to comment.