diff --git a/scripts/helmcharts/databases/charts/clickhouse/templates/clickhouse-cluster.yaml b/scripts/helmcharts/databases/charts/clickhouse/templates/clickhouse-cluster.yaml index 5f9204143..d7ae3068e 100644 --- a/scripts/helmcharts/databases/charts/clickhouse/templates/clickhouse-cluster.yaml +++ b/scripts/helmcharts/databases/charts/clickhouse/templates/clickhouse-cluster.yaml @@ -12,6 +12,9 @@ spec: serviceTemplate: chi-service-template configuration: + # Ref: https://github.com/Altinity/clickhouse-operator/issues/823 + users: + default/networks/ip: "::/0" zookeeper: nodes: - host: "{{ .Values.global.kafka.zookeeperHost }}" @@ -19,8 +22,8 @@ spec: clusters: - name: replicated layout: - shardsCount: 1 - replicasCount: 2 + shardsCount: {{ .Values.clickhouse.replicaCount }} + replicasCount: {{ .Values.clickhouse.shardsCount }} templates: volumeClaimTemplates: @@ -91,4 +94,16 @@ spec: - name: client port: 9000 type: ClusterIP + - name: cluster-template + generateName: "clickhouse" + metadata: + labels: + installation: "openreplay" + spec: + ports: + - name: http + port: 8123 + - name: client + port: 9000 + type: ClusterIP diff --git a/scripts/helmcharts/databases/charts/clickhouse/values.yaml b/scripts/helmcharts/databases/charts/clickhouse/values.yaml index 00689b44d..40dbd4722 100644 --- a/scripts/helmcharts/databases/charts/clickhouse/values.yaml +++ b/scripts/helmcharts/databases/charts/clickhouse/values.yaml @@ -5,6 +5,10 @@ image: storage: size: 200Gi +clickhouse: + replicaCount: 1 + shardsCount: 1 + resources: requests: cpu: 1 diff --git a/scripts/helmcharts/openreplay/charts/alerts/templates/ingress.yaml b/scripts/helmcharts/openreplay/charts/alerts/templates/ingress.yaml index 497e2ec3c..3f1a45d93 100644 --- a/scripts/helmcharts/openreplay/charts/alerts/templates/ingress.yaml +++ b/scripts/helmcharts/openreplay/charts/alerts/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "alerts.fullname" . -}} -{{- $svcPort := .Values.service.port -}} +{{- $svcPort := .Values.service.ports.http -}} {{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} diff --git a/scripts/helmcharts/openreplay/charts/assets/templates/ingress.yaml b/scripts/helmcharts/openreplay/charts/assets/templates/ingress.yaml index 3c6ae561b..25c0d7b9b 100644 --- a/scripts/helmcharts/openreplay/charts/assets/templates/ingress.yaml +++ b/scripts/helmcharts/openreplay/charts/assets/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled }} {{- $fullName := include "assets.fullname" . -}} -{{- $svcPort := .Values.service.port -}} +{{- $svcPort := .Values.service.ports.http -}} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: diff --git a/scripts/helmcharts/openreplay/charts/chalice/templates/ingress.yaml b/scripts/helmcharts/openreplay/charts/chalice/templates/ingress.yaml index d870e7673..ee1120e06 100644 --- a/scripts/helmcharts/openreplay/charts/chalice/templates/ingress.yaml +++ b/scripts/helmcharts/openreplay/charts/chalice/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled }} {{- $fullName := include "chalice.fullname" . -}} -{{- $svcPort := .Values.service.port -}} +{{- $svcPort := .Values.service.ports.http -}} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: diff --git a/scripts/helmcharts/openreplay/charts/chalice/values.yaml b/scripts/helmcharts/openreplay/charts/chalice/values.yaml index 4f79714c9..1a43fc971 100644 --- a/scripts/helmcharts/openreplay/charts/chalice/values.yaml +++ b/scripts/helmcharts/openreplay/charts/chalice/values.yaml @@ -83,7 +83,7 @@ autoscaling: # targetMemoryUtilizationPercentage: 80 env: - ch_host: clickhouse.db.svc.cluster.local + ch_host: clickhouse-openreplay-clickhouse.db.svc.cluster.local ch_port: 9000 captcha_server: '' captcha_key: '' diff --git a/scripts/helmcharts/openreplay/charts/db/templates/ingress.yaml b/scripts/helmcharts/openreplay/charts/db/templates/ingress.yaml index 1cbf3640e..d2818017c 100644 --- a/scripts/helmcharts/openreplay/charts/db/templates/ingress.yaml +++ b/scripts/helmcharts/openreplay/charts/db/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "db.fullname" . -}} -{{- $svcPort := .Values.service.port -}} +{{- $svcPort := .Values.service.ports.http -}} {{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} diff --git a/scripts/helmcharts/openreplay/charts/db/values.yaml b/scripts/helmcharts/openreplay/charts/db/values.yaml index 10e6004ac..1c385926c 100644 --- a/scripts/helmcharts/openreplay/charts/db/values.yaml +++ b/scripts/helmcharts/openreplay/charts/db/values.yaml @@ -90,7 +90,7 @@ autoscaling: # targetMemoryUtilizationPercentage: 80 env: - CLICKHOUSE_STRING: tcp://clickhouse.db.svc.cluster.local:9000/default + CLICKHOUSE_STRING: tcp://clickhouse-openreplay-clickhouse.db.svc.cluster.local:9000/default nodeSelector: {} diff --git a/scripts/helmcharts/openreplay/charts/ender/templates/ingress.yaml b/scripts/helmcharts/openreplay/charts/ender/templates/ingress.yaml index 7f6cc557b..92d772378 100644 --- a/scripts/helmcharts/openreplay/charts/ender/templates/ingress.yaml +++ b/scripts/helmcharts/openreplay/charts/ender/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "ender.fullname" . -}} -{{- $svcPort := .Values.service.port -}} +{{- $svcPort := .Values.service.ports.http -}} {{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} diff --git a/scripts/helmcharts/openreplay/charts/heuristics/templates/ingress.yaml b/scripts/helmcharts/openreplay/charts/heuristics/templates/ingress.yaml index 3d7a13ac2..5f33f48e1 100644 --- a/scripts/helmcharts/openreplay/charts/heuristics/templates/ingress.yaml +++ b/scripts/helmcharts/openreplay/charts/heuristics/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "heuristics.fullname" . -}} -{{- $svcPort := .Values.service.port -}} +{{- $svcPort := .Values.service.ports.http -}} {{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} diff --git a/scripts/helmcharts/openreplay/charts/http/templates/ingress.yaml b/scripts/helmcharts/openreplay/charts/http/templates/ingress.yaml index 8888c7ae9..0adaf68e7 100644 --- a/scripts/helmcharts/openreplay/charts/http/templates/ingress.yaml +++ b/scripts/helmcharts/openreplay/charts/http/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled }} {{- $fullName := include "http.fullname" . -}} -{{- $svcPort := .Values.service.port -}} +{{- $svcPort := .Values.service.ports.http -}} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: diff --git a/scripts/helmcharts/openreplay/charts/integrations/templates/ingress.yaml b/scripts/helmcharts/openreplay/charts/integrations/templates/ingress.yaml index 236409677..10afe84e6 100644 --- a/scripts/helmcharts/openreplay/charts/integrations/templates/ingress.yaml +++ b/scripts/helmcharts/openreplay/charts/integrations/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "integrations.fullname" . -}} -{{- $svcPort := .Values.service.port -}} +{{- $svcPort := .Values.service.ports.http -}} {{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} diff --git a/scripts/helmcharts/openreplay/charts/sink/templates/ingress.yaml b/scripts/helmcharts/openreplay/charts/sink/templates/ingress.yaml index ac5b25ba2..b7cd7fd99 100644 --- a/scripts/helmcharts/openreplay/charts/sink/templates/ingress.yaml +++ b/scripts/helmcharts/openreplay/charts/sink/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "sink.fullname" . -}} -{{- $svcPort := .Values.service.port -}} +{{- $svcPort := .Values.service.ports.http -}} {{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} diff --git a/scripts/helmcharts/openreplay/charts/storage/templates/ingress.yaml b/scripts/helmcharts/openreplay/charts/storage/templates/ingress.yaml index 10bf66e98..880b16f62 100644 --- a/scripts/helmcharts/openreplay/charts/storage/templates/ingress.yaml +++ b/scripts/helmcharts/openreplay/charts/storage/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "storage.fullname" . -}} -{{- $svcPort := .Values.service.port -}} +{{- $svcPort := .Values.service.ports.http -}} {{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} diff --git a/scripts/helmcharts/openreplay/files/clickhouse.sh b/scripts/helmcharts/openreplay/files/clickhouse.sh index 3f9c2954e..3cf48cc93 100644 --- a/scripts/helmcharts/openreplay/files/clickhouse.sh +++ b/scripts/helmcharts/openreplay/files/clickhouse.sh @@ -11,7 +11,7 @@ function migrate() { echo "Migrating clickhouse version $version" # For now, we can ignore the clickhouse db inject errors. # TODO: Better error handling in script - clickhouse-client -h clickhouse.db.svc.cluster.local --port 9000 < ${clickhousedir}/${version}/${version}.sql || true + clickhouse-client -h clickhouse-openreplay-clickhouse.db.svc.cluster.local --port 9000 < ${clickhousedir}/${version}/${version}.sql || true done } @@ -19,7 +19,7 @@ function init() { echo "Initializing clickhouse" for file in `ls ${clickhousedir}/create/*.sql`; do echo "Injecting $file" - clickhouse-client -h clickhouse.db.svc.cluster.local --port 9000 < $file || true + clickhouse-client -h clickhouse-openreplay-clickhouse.db.svc.cluster.local --port 9000 < $file || true done } diff --git a/scripts/helmcharts/openreplay/templates/job.yaml b/scripts/helmcharts/openreplay/templates/job.yaml index 8eedf6f62..980eab56b 100644 --- a/scripts/helmcharts/openreplay/templates/job.yaml +++ b/scripts/helmcharts/openreplay/templates/job.yaml @@ -38,6 +38,27 @@ spec: git clone https://github.com/openreplay/openreplay /opt/openreplay/openreplay -b {{ .Chart.AppVersion }} # Checking variable is empty. Shell independant method. if [ "x$ENTERPRISE_EDITION_LICENSE" != "x" ]; then + exit_count=0 + error_connection=1 + + while [ $exit_count -le 20 ];do + nc -zv clickhouse-openreplay-clickhouse.db.svc.cluster.local 9000 -w 1 + if [ $? -ne 0 ]; then + echo "[info] clickhouse is not up; retrying in 5 seconds" + sleep 4 + exit_count=$(($exit_count+1)) + echo $exit_count + else + error_connection=0 + break + fi + done + + if [ $error_connection -eq 1 ]; then + echo "[error] clickhouse is not running. Check kubectl get po -n db; exiting" + exit 100 + fi + echo "Copying enterprise code" cd /opt/openreplay/openreplay cp -rf ee/scripts/* scripts/