Skip to content

Commit

Permalink
[Helm] Update configuration to allow use of an external clickhouse in…
Browse files Browse the repository at this point in the history
…stance (#8048)
  • Loading branch information
azhavoro committed Jun 25, 2024
1 parent 8c4fc83 commit cdf50d3
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Added

- \[Helm\] Ability to use an external ClickHouse instance
(<https://github.com/cvat-ai/cvat/pull/8048>)
2 changes: 1 addition & 1 deletion components/analytics/vector/vector.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ table = "events"
auth.strategy = "basic"
auth.user = "${CLICKHOUSE_USER}"
auth.password = "${CLICKHOUSE_PASSWORD}"
endpoint = "http://${CLICKHOUSE_HOST}:8123"
endpoint = "http://${CLICKHOUSE_HOST}:${CLICKHOUSE_PORT}"
request.concurrency = "adaptive"
encoding.only_fields = [
"scope",
Expand Down
4 changes: 2 additions & 2 deletions helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.13.1
version: 0.13.2

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down Expand Up @@ -44,7 +44,7 @@ dependencies:
- name: clickhouse
version: "4.1.*"
repository: https://charts.bitnami.com/bitnami
condition: analytics.enabled
condition: clickhouse.enabled

- name: grafana
version: "6.60.*"
Expand Down
32 changes: 30 additions & 2 deletions helm-chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ The name of the service account to use for backend pods
value: "{{ .Release.Name }}-vector"
- name: DJANGO_LOG_SERVER_PORT
value: "80"
- name: CLICKHOUSE_HOST
value: "{{ .Release.Name }}-clickhouse"
{{- end }}

- name: SMOKESCREEN_OPTS
Expand All @@ -141,3 +139,33 @@ The name of the service account to use for backend pods
value: "{{ .Release.Namespace }}"
{{- end }}
{{- end }}

{{- define "cvat.sharedClickhouseEnv" }}
{{- if .Values.analytics.enabled }}
- name: CLICKHOUSE_HOST
valueFrom:
secretKeyRef:
name: cvat-analytics-secret
key: CLICKHOUSE_HOST
- name: CLICKHOUSE_PORT
valueFrom:
secretKeyRef:
name: cvat-analytics-secret
key: CLICKHOUSE_PORT
- name: CLICKHOUSE_DB
valueFrom:
secretKeyRef:
name: cvat-analytics-secret
key: CLICKHOUSE_DB
- name: CLICKHOUSE_USER
valueFrom:
secretKeyRef:
name: cvat-analytics-secret
key: CLICKHOUSE_USER
- name: CLICKHOUSE_PASSWORD
valueFrom:
secretKeyRef:
name: cvat-analytics-secret
key: CLICKHOUSE_PASSWORD
{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions helm-chart/templates/analytics/cvat-analytics-secret.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ stringData:
CLICKHOUSE_USER: {{ .Values.analytics.clickhouseUser }}
CLICKHOUSE_PASSWORD: {{ .Values.analytics.clickhousePassword }}
CLICKHOUSE_HOST: {{ tpl (.Values.analytics.clickhouseHost) . }}
CLICKHOUSE_PORT: {{ .Values.analytics.clickhousePort | quote }}
{{- end }}
1 change: 1 addition & 0 deletions helm-chart/templates/cvat_backend/server/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ spec:
- name: ALLOWED_HOSTS
value: {{ $localValues.envs.ALLOWED_HOSTS | squote}}
{{ include "cvat.sharedBackendEnv" . | indent 10 }}
{{ include "cvat.sharedClickhouseEnv" . | indent 10 }}
{{- with concat .Values.cvat.backend.additionalEnv $localValues.additionalEnv }}
{{- toYaml . | nindent 10 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ spec:
args: ["run", "worker.analytics_reports"]
env:
{{ include "cvat.sharedBackendEnv" . | indent 10 }}
{{ include "cvat.sharedClickhouseEnv" . | indent 10 }}
{{- with concat .Values.cvat.backend.additionalEnv $localValues.additionalEnv }}
{{- toYaml . | nindent 10 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ spec:
args: ["run", "worker.export"]
env:
{{ include "cvat.sharedBackendEnv" . | indent 10 }}
{{ include "cvat.sharedClickhouseEnv" . | indent 10 }}
{{- with concat .Values.cvat.backend.additionalEnv $localValues.additionalEnv }}
{{- toYaml . | nindent 10 }}
{{- end }}
Expand Down
16 changes: 11 additions & 5 deletions helm-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,13 @@ nuclio:
# password: somepass

analytics:
# Set clickhouse.enabled to false if you disable analytics or use an external database
enabled: true
clickhouseDb: cvat
clickhouseUser: user
clickhousePassword: user
clickhouseHost: "{{ .Release.Name }}-clickhouse"
clickhousePort: 8123

vector:
envFrom:
Expand All @@ -347,6 +349,8 @@ vector:
tag: "0.26.0-alpine"

clickhouse:
# Set to false in case of external db usage
enabled: true
shards: 1
replicaCount: 1
extraEnvVarsSecret: cvat-analytics-secret
Expand All @@ -360,6 +364,7 @@ clickhouse:
enabled: false

grafana:
envFromSecret: cvat-analytics-secret
datasources:
datasources.yaml:
apiVersion: 1
Expand All @@ -368,13 +373,14 @@ grafana:
type: 'grafana-clickhouse-datasource'
isDefault: true
jsonData:
defaultDatabase: cvat
port: 9000
server: "{{ .Release.Name }}-clickhouse"
username: user
defaultDatabase: ${CLICKHOUSE_DB}
port: ${CLICKHOUSE_PORT}
server: ${CLICKHOUSE_HOST}
username: ${CLICKHOUSE_USER}
tlsSkipVerify: false
protocol: http
secureJsonData:
password: user
password: ${CLICKHOUSE_PASSWORD}
editable: false
dashboardProviders:
dashboardproviders.yaml:
Expand Down

0 comments on commit cdf50d3

Please sign in to comment.