Skip to content

Commit

Permalink
add clickhouse backup (#195)
Browse files Browse the repository at this point in the history
* add backup for clickhouse

* fix resources for clickhouse

* Update Helm documentation

---------

Co-authored-by: CometActions <[email protected]>
  • Loading branch information
liyaka and CometActions authored Sep 8, 2024
1 parent bded09e commit 10a23d0
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
1 change: 1 addition & 0 deletions deployment/helm_chart/opik/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"` | |
Expand Down
Original file line number Diff line number Diff line change
@@ -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}}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
6 changes: 6 additions & 0 deletions deployment/helm_chart/opik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ clickhouse:
enabled: false
username: opik
password: opik
backup:
enabled: false
# bucketName: ""
# region: ""
# secretName: ""
# schedule: ""
operator:
enabled: true

Expand Down

0 comments on commit 10a23d0

Please sign in to comment.