Skip to content

Commit

Permalink
helm: add cronjob to apply pending retention rules
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonadoni committed Jul 22, 2022
1 parent af5360f commit 558f41d
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Version 0.9.0 (UNRELEASED)
- Adds support for Kubernetes clusters 1.22, 1.23, 1.24.
- Removes support for Kubernetes version prior to 1.19.
- Adds new configuration option ``workspaces.retention_rules.maximum_period`` to set a default period for workspace retention rules.
- Adds new configuration option ``workspaces.retention_rules.cronjob_schedule`` to set how often pending retention rules should be applied.
- Adds configuration environment variable ``reana_server.environment.REANA_RATELIMIT_SLOW`` to limit API requests to some protected endpoints e.g launch workflow.
- Adds configuration environment variable ``reana_server.environment.REANA_WORKFLOW_SCHEDULING_READINESS_CHECK_LEVEL`` to define checks that are performed to assess whether the cluster is ready to start new workflows.
- Adds new configuration option `ingress.tls.self_signed_cert` to enable the generation of a self-signed TLS certificate.
Expand Down
1 change: 1 addition & 0 deletions helm/reana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,5 @@ This Helm automatically prefixes all names using the release name to avoid colli
| `quota.default_disk_limit` | Default users disk quota limit in bytes. | None |
| `quota.default_cpu_limit` | Default users CPU quota limit in milliseconds. | None |
| `workspaces.retention_rules.maximum_period` | Set a default period in days for workspace retention rules. Users will not be able to specify a longer period to retain the workspace files. After this period the workspace will be cleared. | 365 |
| `workspaces.retention_rules.cronjob_schedule` | Cron format string describing how often pending retention rules should be applied. | "0 2 * * *" |
| `workspaces.paths` | List of additional workspace paths as strings. Each mount string is composed by a key `hostPath`(path to the directory to be mounted from the Kubernetes nodes) and a cluster_pod_mountpath (path inside the cluster containers where the `mountPath` will be mounted) e.g. `hostPath:mountPath`. The first value listed will be the default workspace root path. Any POSIX filesystem mounted on cluster nodes is supported | None |
69 changes: 69 additions & 0 deletions helm/reana/templates/cronjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,72 @@ spec:
hostPath:
path: /code/reana-server
{{- end }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "reana.prefix" . }}-retention-rules-apply
namespace: {{ .Release.Namespace }}
spec:
schedule: {{ .Values.workspaces.retention_rules.cronjob_schedule }}
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
spec:
containers:
- name: {{ include "reana.prefix" . }}-retention-rules-apply
image: {{ .Values.components.reana_server.image }}
command:
- '/bin/sh'
- '-c'
args:
- 'flask reana-admin retention-rules-apply'
{{- if .Values.debug.enabled }}
tty: true
stdin: true
{{- end }}
env:
{{- range $key, $value := .Values.db_env_config }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- if .Values.debug.enabled }}
- name: FLASK_ENV
value: "development"
{{- else }}
- name: REANA_DB_USERNAME
valueFrom:
secretKeyRef:
name: {{ include "reana.prefix" . }}-db-secrets
key: user
- name: REANA_DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "reana.prefix" . }}-db-secrets
key: password
{{- end }}
volumeMounts:
{{- if .Values.debug.enabled }}
- mountPath: /code/
name: reana-code
{{- end }}
- mountPath: {{ .Values.shared_storage.shared_volume_mount_path }}
name: reana-shared-volume
imagePullPolicy: IfNotPresent
restartPolicy: Never
volumes:
- name: reana-shared-volume
{{- if not (eq .Values.shared_storage.backend "hostpath") }}
persistentVolumeClaim:
claimName: {{ include "reana.prefix" . }}-shared-persistent-volume
readOnly: false
{{- else }}
hostPath:
path: {{ .Values.shared_storage.hostpath.root_path }}
{{- end }}
- name: reana-code
hostPath:
path: /code/reana-server
1 change: 1 addition & 0 deletions helm/reana/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ eos:
workspaces:
retention_rules:
maximum_period: 365
cronjob_schedule: "0 2 * * *" # everyday at 2am
paths:
- /var/reana:/var/reana

Expand Down

0 comments on commit 558f41d

Please sign in to comment.