diff --git a/deployment/helm_chart/opik/README.md b/deployment/helm_chart/opik/README.md index 3d6e1b6e20..3457fda2c2 100644 --- a/deployment/helm_chart/opik/README.md +++ b/deployment/helm_chart/opik/README.md @@ -93,6 +93,7 @@ Call opik api on http://localhost:5173/api | clickhouse.adminUser.password | string | `"opik"` | | | clickhouse.adminUser.useSecret.enabled | bool | `false` | | | clickhouse.adminUser.username | string | `"opik"` | | +| clickhouse.backup.enabled | bool | `false` | | | clickhouse.image | string | `"altinity/clickhouse-server:24.3.5.47.altinitystable"` | | | clickhouse.logsLevel | string | `"information"` | | | clickhouse.namePrefix | string | `"opik"` | | diff --git a/deployment/helm_chart/opik/templates/clickhouse-backup-cronjob.yaml b/deployment/helm_chart/opik/templates/clickhouse-backup-cronjob.yaml new file mode 100644 index 0000000000..e9f1991456 --- /dev/null +++ b/deployment/helm_chart/opik/templates/clickhouse-backup-cronjob.yaml @@ -0,0 +1,44 @@ +{{ if .Values.clickhouse.backup.enabled }} +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ include "opik.name" $ }}-clickhouse-backup +spec: + schedule: "{{ .Values.clickhouse.backup.schedule }}" + jobTemplate: + spec: + template: + spec: + containers: + - name: clickhouse-backup-job + image: {{ .Values.clickhouse.image }} + command: + - "/bin/bash" + - "-c" + args: + - export backupname=backup$(date +'%Y%m%d%H'); echo "BACKUP ALL TO S3('https://{{ .Values.clickhouse.backup.bucketName }}.s3.{{ .Values.clickhouse.backup.region }}.amazonaws.com/$backupname/', '$ACCESS_KEY', '"$SECRET_KEY"')" > /tmp/backQuery.sql; clickhouse-client -h clickhouse-opik-clickhouse --send_timeout 600000 --receive_timeout 600000 --port 9000 --queries-file=/tmp/backQuery.sql; + env: + - name: CLICKHOUSE_USER + value: {{ .Values.clickhouse.adminUser.username }} + - name: CLICKHOUSE_PASSWORD + {{- if .Values.clickhouse.adminUser.useSecret.enabled }} + valueFrom: + secretKeyRef: + name: {{ include "opik.name" .}}-{{ .Values.clickhouse.adminUser.secretname }} + key: {{ .Values.clickhouse.adminUser.password_key }} + {{- else }} + value: {{ .Values.clickhouse.adminUser.password }} + {{- end }} + - name: ACCESS_KEY + valueFrom: + secretKeyRef: + name: {{ .Values.clickhouse.backup.secretName}} + key: access_key_id + - name: SECRET_KEY + valueFrom: + secretKeyRef: + name: {{ .Values.clickhouse.backup.secretName}} + key: access_key_secret + restartPolicy: Never + backoffLimit: +{{end}} diff --git a/deployment/helm_chart/opik/templates/clickhouseinstallation.yml b/deployment/helm_chart/opik/templates/clickhouseinstallation.yaml similarity index 98% rename from deployment/helm_chart/opik/templates/clickhouseinstallation.yml rename to deployment/helm_chart/opik/templates/clickhouseinstallation.yaml index 1e70252190..e7a2fceef2 100644 --- a/deployment/helm_chart/opik/templates/clickhouseinstallation.yml +++ b/deployment/helm_chart/opik/templates/clickhouseinstallation.yaml @@ -42,7 +42,7 @@ spec: image: {{ .Values.clickhouse.image }} {{- with .Values.clickhouse.resources }} resources: - {{- toYaml . | nindent 12 }} + {{- toYaml . | nindent 14 }} {{- end }} {{- with .Values.clickhouse.nodeSelector }} diff --git a/deployment/helm_chart/opik/values.yaml b/deployment/helm_chart/opik/values.yaml index 40cc64b1c5..fd006287ac 100644 --- a/deployment/helm_chart/opik/values.yaml +++ b/deployment/helm_chart/opik/values.yaml @@ -176,6 +176,12 @@ clickhouse: enabled: false username: opik password: opik + backup: + enabled: false + # bucketName: "" + # region: "" + # secretName: "" + # schedule: "" operator: enabled: true