fix(helm): clickhouse upgrade script

Signed-off-by: Rajesh Rajendran <rjshrjndrn@gmail.com>
This commit is contained in:
Rajesh Rajendran 2021-12-12 19:06:21 +05:30
parent 7f1daf01c7
commit c2f8398a85
No known key found for this signature in database
GPG key ID: F9F6FCAB8BACB638
5 changed files with 51 additions and 6 deletions

View file

@ -1 +0,0 @@
#!/bin/bash

View file

@ -0,0 +1,35 @@
#!/bin/bash
set -e
clickhousedir=/opt/openreplay/openreplay/scripts/helm/db/init_dbs/clickhouse
function migrate() {
echo "Starting postgresql migration"
migration_versions=$1
for version in $migration_versions; do
echo "Migrating postgresql version $version"
clickhouse-client -h clickhouse.db.svc.cluster.local -p 9000 < ${clickhousedir}/${version}/${version}.sql
done
}
function init() {
echo "Initializing postgresql"
for file in `ls ${clickhousedir}/create/*.sql`; do
clickhouse-client -h clickhouse.db.svc.cluster.local -p 9000 < $file
done
}
# /bin/bash postgresql.sh migrate $migration_versions
case "$1" in
migrate)
migrate $2
;;
init)
init
;;
*)
echo "Unknown operation for clickhouse migration; exiting."
exit 1
;;
esac

View file

@ -46,6 +46,12 @@ function init(){
postgresql)
/bin/bash postgresql.sh init
;;
clickhouse)
/bin/bash clickhouse.sh init
;;
kafka)
/bin/bash kafka.sh init
;;
*)
echo "Unknown operation for db init; exiting."
exit 1

View file

@ -67,11 +67,12 @@ spec:
- name: dbmigrationscript
mountPath: /opt/migrations/
- name: clickhouse
image: yandex/clickhouse-server:20.9
image: yandex/clickhouse-client:20.9
command:
- /bin/bash
- /opt/migration.sh
- /opt/migrations/dbops.sh
- "{{ .Release.IsUpgrade }}"
- clickhouse
volumeMounts:
- name: shared
mountPath: /opt/openreplay
@ -83,6 +84,7 @@ spec:
- /bin/bash
- /opt/migration.sh
- "{{ .Release.IsUpgrade }}"
- kafka
volumeMounts:
- name: shared
mountPath: /opt/openreplay

View file

@ -1,7 +1,7 @@
postgresql:
# For genrating psswords
# `openssl rand -hex 20`
postgresqlPassword: "asdfasdfasdcasdc"
postgresqlPassword: "changeMePassword"
postgresqlHost: "postgresql.db.svc.cluster.local"
postgresqlPort: "5432"
postgresqlUser: "postgres"
@ -12,5 +12,8 @@ minio:
minio:
# For genrating psswords
# `openssl rand -hex 20`
accessKey: "sasdcasdcasd"
secretKey: "sdvasdfasdfasdf"
accessKey: "changeMePassword"
secretKey: "changeMePassword"
global:
enterprise_edition_license: ""