openreplay/scripts/helmcharts/databases/charts/clickhouse/templates/statefulset.yaml
rjshrjndrn 3272f5b9fd refactor(clickhouse): split server and user config
Split the ClickHouse configuration into separate ConfigMaps for server
and user configurations. This allows more granular management of the
different configuration types and proper mounting to their respective
paths.

- Created separate serverConfig and userConfig under configOverride
- Added user-default.xml under userConfig
- Updated StatefulSet to mount each ConfigMap separately

Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>
2025-04-11 17:20:26 +02:00

110 lines
3.7 KiB
YAML

apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "clickhouse.fullname" . }}
labels:
{{- include "clickhouse.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
serviceName: {{ include "clickhouse.fullname" . }}
selector:
matchLabels:
{{- include "clickhouse.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "clickhouse.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "clickhouse.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}-backup
env:
- name: CLICKHOUSE_USER
value: "{{ .Values.username }}"
- name: CLICKHOUSE_PASSWORD
value: "{{ .Values.password }}"
{{- range $key, $value := .Values.backupEnv }}
- name: "{{ $key }}"
value: "{{ $value }}"
{{- end }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.backupImage.repository }}:{{ .Values.backupImage.tag }}"
imagePullPolicy: {{ .Values.backupImage.pullPolicy }}
args:
- server
ports:
- containerPort: 7171
name: backup-web
volumeMounts:
- name: default-chi-openreplay-clickhouse-replicated-0-0-0
mountPath: /var/lib/clickhouse
- name: {{ .Chart.Name }}
env:
- name: CLICKHOUSE_USER
value: "{{ .Values.username }}"
- name: CLICKHOUSE_PASSWORD
value: "{{ .Values.password }}"
- name: CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT
value: "1"
{{- range $key, $value := .Values.env }}
- name: "{{ $key }}"
value: "{{ $value }}"
{{- end }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 9000
name: web
- containerPort: 8123
name: data
volumeMounts:
- name: default-chi-openreplay-clickhouse-replicated-0-0-0
mountPath: /var/lib/clickhouse
- name: clickhouse-override-server-config
mountPath: /etc/clickhouse-server/config.d
- name: clickhouse-override-user-config
mountPath: /etc/clickhouse-server/config.d
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: clickhouse-override-server-config
configMap:
name: clickhouse-server-override
optional: true
- name: clickhouse-override-user-config
configMap:
name: clickhouse-user-override
optional: true
volumeClaimTemplates:
- metadata:
name: default-chi-openreplay-clickhouse-replicated-0-0-0
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: {{ .Values.storageSize }}