Fixes related to clickhouse and service Port for ingress (#510)

* chore(helm): variablizing clickhouse shards/replica

Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>

* chore(clickhouse): adding new template for clickhouse cluster

Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>

* chore(helm): enable passwordless clickhouse

Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>

* chore(install): check clickhouse is up prior initialization

Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>

* fix(helm): port value for ingress
This commit is contained in:
Rajesh Rajendran 2022-05-25 16:53:24 +00:00 committed by GitHub
parent 55a0d3a0e0
commit 3a2b54a446
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 56 additions and 16 deletions

View file

@ -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

View file

@ -5,6 +5,10 @@ image:
storage:
size: 200Gi
clickhouse:
replicaCount: 1
shardsCount: 1
resources:
requests:
cpu: 1

View file

@ -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}}

View file

@ -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:

View file

@ -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:

View file

@ -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: ''

View file

@ -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}}

View file

@ -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: {}

View file

@ -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}}

View file

@ -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}}

View file

@ -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:

View file

@ -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}}

View file

@ -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}}

View file

@ -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}}

View file

@ -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
}

View file

@ -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/