|
| 1 | +{{- if .Values.clickhouse.deploy }} |
| 2 | +apiVersion: v1 |
| 3 | +kind: ConfigMap |
| 4 | +metadata: |
| 5 | + name: {{ include "trigger-v4.fullname" . }}-clickhouse-config |
| 6 | + labels: |
| 7 | + {{- $component := "clickhouse" }} |
| 8 | + {{- include "trigger-v4.componentLabels" (dict "Chart" .Chart "Release" .Release "Values" .Values "component" $component) | nindent 4 }} |
| 9 | +data: |
| 10 | + {{- if not (hasKey .Values.clickhouse.configdFiles "data-paths.xml") }} |
| 11 | + {{- /* Keeps the on-disk layout compatible with data volumes created by the |
| 12 | + Bitnami subchart this chart used previously, which stored everything |
| 13 | + under a data/ subdirectory of the volume. Fresh installs get the same |
| 14 | + layout. tmp lives outside data/ because old volumes contain a |
| 15 | + dangling tmp symlink there. */}} |
| 16 | + data-paths.xml: | |
| 17 | + <clickhouse> |
| 18 | + <path>/var/lib/clickhouse/data/</path> |
| 19 | + <tmp_path>/var/lib/clickhouse/tmp/</tmp_path> |
| 20 | + <user_files_path>/var/lib/clickhouse/data/user_files/</user_files_path> |
| 21 | + <format_schema_path>/var/lib/clickhouse/data/format_schemas/</format_schema_path> |
| 22 | + <user_directories> |
| 23 | + <local_directory> |
| 24 | + <path>/var/lib/clickhouse/data/access/</path> |
| 25 | + </local_directory> |
| 26 | + </user_directories> |
| 27 | + </clickhouse> |
| 28 | + {{- end }} |
| 29 | + {{- range $filename, $content := .Values.clickhouse.configdFiles }} |
| 30 | + {{ $filename }}: | |
| 31 | + {{- $content | nindent 4 }} |
| 32 | + {{- end }} |
| 33 | +--- |
| 34 | +{{- /* Reuse an existing data PVC instead of creating one via |
| 35 | + volumeClaimTemplates. Set explicitly through persistence.existingClaim, |
| 36 | + or detected automatically: upgrades from chart versions that bundled |
| 37 | + the Bitnami subchart leave their PVC behind under the old name, and |
| 38 | + adopting it preserves all ClickHouse data with no manual migration. |
| 39 | + (lookup returns nothing during template/dry-run rendering; set |
| 40 | + persistence.existingClaim explicitly when pre-rendering manifests, |
| 41 | + e.g. with GitOps tools.) */}} |
| 42 | +{{- $existingClaim := .Values.clickhouse.persistence.existingClaim }} |
| 43 | +{{- if and (not $existingClaim) .Values.clickhouse.persistence.enabled }} |
| 44 | +{{- $legacyName := printf "data-%s-clickhouse-shard0-0" .Release.Name }} |
| 45 | +{{- if lookup "v1" "PersistentVolumeClaim" .Release.Namespace $legacyName }} |
| 46 | +{{- $existingClaim = $legacyName }} |
| 47 | +{{- end }} |
| 48 | +{{- end }} |
| 49 | +apiVersion: apps/v1 |
| 50 | +kind: StatefulSet |
| 51 | +metadata: |
| 52 | + name: {{ include "trigger-v4.fullname" . }}-clickhouse |
| 53 | + labels: |
| 54 | + {{- $component := "clickhouse" }} |
| 55 | + {{- include "trigger-v4.componentLabels" (dict "Chart" .Chart "Release" .Release "Values" .Values "component" $component) | nindent 4 }} |
| 56 | +spec: |
| 57 | + replicas: 1 |
| 58 | + serviceName: {{ include "trigger-v4.fullname" . }}-clickhouse |
| 59 | + selector: |
| 60 | + matchLabels: |
| 61 | + {{- include "trigger-v4.componentSelectorLabels" (dict "Chart" .Chart "Release" .Release "Values" .Values "component" $component) | nindent 6 }} |
| 62 | + template: |
| 63 | + metadata: |
| 64 | + annotations: |
| 65 | + checksum/config: {{ .Values.clickhouse.configdFiles | toYaml | sha256sum }} |
| 66 | + {{- with .Values.clickhouse.podAnnotations }} |
| 67 | + {{- toYaml . | nindent 8 }} |
| 68 | + {{- end }} |
| 69 | + labels: |
| 70 | + {{- include "trigger-v4.componentSelectorLabels" (dict "Chart" .Chart "Release" .Release "Values" .Values "component" $component) | nindent 8 }} |
| 71 | + spec: |
| 72 | + {{- with .Values.global.imagePullSecrets }} |
| 73 | + imagePullSecrets: |
| 74 | + {{- toYaml . | nindent 8 }} |
| 75 | + {{- end }} |
| 76 | + {{- with .Values.clickhouse.podSecurityContext }} |
| 77 | + securityContext: |
| 78 | + {{- toYaml . | nindent 8 }} |
| 79 | + {{- end }} |
| 80 | + containers: |
| 81 | + - name: clickhouse |
| 82 | + {{- with .Values.clickhouse.securityContext }} |
| 83 | + securityContext: |
| 84 | + {{- toYaml . | nindent 12 }} |
| 85 | + {{- end }} |
| 86 | + image: "{{ .Values.global.imageRegistry | default .Values.clickhouse.image.registry }}/{{ .Values.clickhouse.image.repository }}:{{ .Values.clickhouse.image.tag }}{{ with .Values.clickhouse.image.digest }}@{{ . }}{{ end }}" |
| 87 | + imagePullPolicy: {{ .Values.clickhouse.image.pullPolicy }} |
| 88 | + env: |
| 89 | + - name: CLICKHOUSE_USER |
| 90 | + value: {{ .Values.clickhouse.auth.username | quote }} |
| 91 | + - name: CLICKHOUSE_PASSWORD |
| 92 | + value: {{ .Values.clickhouse.auth.password | quote }} |
| 93 | + - name: CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT |
| 94 | + value: "1" |
| 95 | + ports: |
| 96 | + - name: http |
| 97 | + containerPort: 8123 |
| 98 | + protocol: TCP |
| 99 | + - name: native |
| 100 | + containerPort: 9000 |
| 101 | + protocol: TCP |
| 102 | + {{- if .Values.clickhouse.livenessProbe.enabled }} |
| 103 | + livenessProbe: |
| 104 | + httpGet: |
| 105 | + path: /ping |
| 106 | + port: http |
| 107 | + initialDelaySeconds: {{ .Values.clickhouse.livenessProbe.initialDelaySeconds }} |
| 108 | + periodSeconds: {{ .Values.clickhouse.livenessProbe.periodSeconds }} |
| 109 | + timeoutSeconds: {{ .Values.clickhouse.livenessProbe.timeoutSeconds }} |
| 110 | + failureThreshold: {{ .Values.clickhouse.livenessProbe.failureThreshold }} |
| 111 | + successThreshold: {{ .Values.clickhouse.livenessProbe.successThreshold }} |
| 112 | + {{- end }} |
| 113 | + {{- if .Values.clickhouse.readinessProbe.enabled }} |
| 114 | + readinessProbe: |
| 115 | + httpGet: |
| 116 | + path: /ping |
| 117 | + port: http |
| 118 | + initialDelaySeconds: {{ .Values.clickhouse.readinessProbe.initialDelaySeconds }} |
| 119 | + periodSeconds: {{ .Values.clickhouse.readinessProbe.periodSeconds }} |
| 120 | + timeoutSeconds: {{ .Values.clickhouse.readinessProbe.timeoutSeconds }} |
| 121 | + failureThreshold: {{ .Values.clickhouse.readinessProbe.failureThreshold }} |
| 122 | + successThreshold: {{ .Values.clickhouse.readinessProbe.successThreshold }} |
| 123 | + {{- end }} |
| 124 | + resources: |
| 125 | + {{- toYaml .Values.clickhouse.resources | nindent 12 }} |
| 126 | + volumeMounts: |
| 127 | + - name: data |
| 128 | + mountPath: /var/lib/clickhouse |
| 129 | + - name: logs |
| 130 | + mountPath: /var/log/clickhouse-server |
| 131 | + {{- /* Mount each override file individually: shadowing the whole |
| 132 | + config.d directory would remove the image's built-in |
| 133 | + docker_related_config.xml, which makes the server listen on |
| 134 | + 0.0.0.0 instead of localhost only. */}} |
| 135 | + {{- if not (hasKey .Values.clickhouse.configdFiles "data-paths.xml") }} |
| 136 | + - name: config |
| 137 | + mountPath: /etc/clickhouse-server/config.d/data-paths.xml |
| 138 | + subPath: data-paths.xml |
| 139 | + {{- end }} |
| 140 | + {{- range $filename, $_ := .Values.clickhouse.configdFiles }} |
| 141 | + - name: config |
| 142 | + mountPath: /etc/clickhouse-server/config.d/{{ $filename }} |
| 143 | + subPath: {{ $filename }} |
| 144 | + {{- end }} |
| 145 | + volumes: |
| 146 | + - name: config |
| 147 | + configMap: |
| 148 | + name: {{ include "trigger-v4.fullname" . }}-clickhouse-config |
| 149 | + - name: logs |
| 150 | + emptyDir: {} |
| 151 | + {{- if not .Values.clickhouse.persistence.enabled }} |
| 152 | + - name: data |
| 153 | + emptyDir: {} |
| 154 | + {{- else if $existingClaim }} |
| 155 | + - name: data |
| 156 | + persistentVolumeClaim: |
| 157 | + claimName: {{ $existingClaim }} |
| 158 | + {{- end }} |
| 159 | + {{- if and .Values.clickhouse.persistence.enabled (not $existingClaim) }} |
| 160 | + volumeClaimTemplates: |
| 161 | + - metadata: |
| 162 | + name: data |
| 163 | + {{- if .Values.clickhouse.persistence.retain }} |
| 164 | + annotations: |
| 165 | + helm.sh/resource-policy: keep |
| 166 | + {{- end }} |
| 167 | + spec: |
| 168 | + accessModes: |
| 169 | + - {{ .Values.clickhouse.persistence.accessMode }} |
| 170 | + resources: |
| 171 | + requests: |
| 172 | + storage: {{ .Values.clickhouse.persistence.size }} |
| 173 | + {{- $storageClass := .Values.clickhouse.persistence.storageClass | default .Values.global.storageClass }} |
| 174 | + {{- if $storageClass }} |
| 175 | + storageClassName: {{ $storageClass }} |
| 176 | + {{- end }} |
| 177 | + {{- end }} |
| 178 | +--- |
| 179 | +apiVersion: v1 |
| 180 | +kind: Service |
| 181 | +metadata: |
| 182 | + name: {{ include "trigger-v4.fullname" . }}-clickhouse |
| 183 | + labels: |
| 184 | + {{- $component := "clickhouse" }} |
| 185 | + {{- include "trigger-v4.componentLabels" (dict "Chart" .Chart "Release" .Release "Values" .Values "component" $component) | nindent 4 }} |
| 186 | +spec: |
| 187 | + type: {{ .Values.clickhouse.service.type }} |
| 188 | + ports: |
| 189 | + - port: {{ .Values.clickhouse.service.ports.http }} |
| 190 | + targetPort: http |
| 191 | + protocol: TCP |
| 192 | + name: http |
| 193 | + - port: {{ .Values.clickhouse.service.ports.native }} |
| 194 | + targetPort: native |
| 195 | + protocol: TCP |
| 196 | + name: native |
| 197 | + selector: |
| 198 | + {{- include "trigger-v4.componentSelectorLabels" (dict "Chart" .Chart "Release" .Release "Values" .Values "component" $component) | nindent 4 }} |
| 199 | +{{- end }} |
0 commit comments