diff --git a/addons/clickhouse/configs/00_default_overrides.xml.tpl b/addons/clickhouse/configs/00_default_overrides.xml.tpl index aca356ce3..c87b21021 100644 --- a/addons/clickhouse/configs/00_default_overrides.xml.tpl +++ b/addons/clickhouse/configs/00_default_overrides.xml.tpl @@ -14,37 +14,25 @@ -{{- range $.cluster.spec.componentSpecs }} - {{ $compIter := . }} - {{- if eq $compIter.componentDefRef "clickhouse" }} - {{- $replicas := $compIter.replicas | int }} - {{- range $i, $_e := until $replicas }} + {{- range $_, $host := splitList "," .CLICKHOUSE_POD_FQDN_LIST }} - {{ $clusterName }}-{{ $compIter.name }}-{{ $i }}.{{ $clusterName }}-{{ $compIter.name }}-headless.{{ $namespace }}.svc.{{- $.clusterDomain }} + {{ $host }} 9000 {{- end }} - {{- end }} -{{- end }} -{{- range $.cluster.spec.componentSpecs }} - {{ $compIter := . }} - {{- if or (eq $compIter.componentDefRef "zookeeper") (eq $compIter.componentDefRef "ch-keeper") }} - {{- $replicas := $compIter.replicas | int }} - {{- range $i, $_e := until $replicas }} + {{- range $_, $host := splitList "," .CH_KEEPER_POD_FQDN_LIST }} - {{ $clusterName }}-{{ $compIter.name }}-{{ $i }}.{{ $clusterName }}-{{ $compIter.name }}-headless.{{ $namespace }}.svc.{{- $.clusterDomain }} + {{ $host }} 2181 {{- end }} - {{- end }} -{{- end }} /metrics diff --git a/addons/clickhouse/configs/ch-keeper_00_default_overrides.xml.tpl b/addons/clickhouse/configs/ch-keeper_00_default_overrides.xml.tpl index 1a5577d77..b5d0c164b 100644 --- a/addons/clickhouse/configs/ch-keeper_00_default_overrides.xml.tpl +++ b/addons/clickhouse/configs/ch-keeper_00_default_overrides.xml.tpl @@ -13,11 +13,10 @@ warning -{{- $replicas := $.component.replicas | int }} -{{- range $i, $e := until $replicas }} +{{- range $id, $host := splitList "," .CH_KEEPER_POD_FQDN_LIST }} - {{ $i | int | add1 }} - {{ $clusterName }}-{{ $.component.name }}-{{ $i }}.{{ $clusterName }}-{{ $.component.name }}-headless.{{ $namespace }}.svc.{{- $.clusterDomain }} + {{ $id | add1 }} + {{ $host }} {{- end }} diff --git a/addons/clickhouse/templates/clusterdefinition.yaml b/addons/clickhouse/templates/clusterdefinition.yaml new file mode 100644 index 000000000..e87081a14 --- /dev/null +++ b/addons/clickhouse/templates/clusterdefinition.yaml @@ -0,0 +1,28 @@ +apiVersion: apps.kubeblocks.io/v1alpha1 +kind: ClusterDefinition +metadata: + name: clickhouse + labels: + {{- include "clickhouse.labels" . | nindent 4 }} + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} + {{- end }} + {{- if .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} + {{- end }} +spec: + topologies: + - name: standalone + components: + - name: clickhouse + compDef: clickhouse + - name: clickhouse-cluster + components: + - name: clickhouse + compDef: clickhouse-22 + - name: ch-keeper + compDef: clickhouse-keeper-22 + orders: + provision: + - ch-keeper + - clickhouse \ No newline at end of file diff --git a/addons/clickhouse/templates/cmpd.yaml b/addons/clickhouse/templates/cmpd-ch.yaml similarity index 86% rename from addons/clickhouse/templates/cmpd.yaml rename to addons/clickhouse/templates/cmpd-ch.yaml index 73a29fc61..00c1d1b3a 100644 --- a/addons/clickhouse/templates/cmpd.yaml +++ b/addons/clickhouse/templates/cmpd-ch.yaml @@ -1,7 +1,7 @@ apiVersion: apps.kubeblocks.io/v1alpha1 kind: ComponentDefinition metadata: - name: clickhouse-{{ .Chart.Version }} + name: clickhouse-22 labels: {{- include "clickhouse.labels" . | nindent 4 }} {{- if .Values.commonLabels }} @@ -14,7 +14,71 @@ spec: provider: ApeCloud description: {{ .Chart.Description }} serviceKind: {{ .Chart.Name }} - serviceVersion: {{ .Chart.AppVersion }} + serviceVersion: 22.9.4 + services: + - name: default + spec: + ports: + - name: http + targetPort: http + port: 8123 + - name: tcp + targetPort: tcp + port: 9000 + - name: tcp-mysql + targetPort: tcp-mysql + port: 9004 + - name: tcp-postgresql + targetPort: tcp-postgresql + port: 9005 + - name: http-intersrv + targetPort: http-intersrv + port: 9009 + - name: http-metrics + targetPort: http-metrics + port: 8001 + logConfigs: + {{- range $name, $pattern := .Values.logConfigs }} + - name: {{ $name }} + filePathPattern: {{ $pattern }} + {{- end }} + exporter: + scrapePath: /metrics + scrapePort: "8001" + configs: + - name: clickhouse-tpl + templateRef: clickhouse-tpl + volumeName: config + namespace: {{ .Release.Namespace }} + - name: clickhouse-user-tpl + templateRef: clickhouse-user-tpl + volumeName: user-config + namespace: {{ .Release.Namespace }} + constraintRef: clickhouse-constraints + systemAccounts: + - name: admin + initAccount: true + vars: + - name: CLICKHOUSE_ADMIN_USER + value: admin + - name: CLICKHOUSE_ADMIN_PASSWORD + valueFrom: + credentialVarRef: + name: admin + compDef: clickhouse-keeper-22 + optional: false + password: Required + - name: CLICKHOUSE_POD_FQDN_LIST + valueFrom: + componentVarRef: + optional: false + podFQDNs: Required + - name: CH_KEEPER_POD_FQDN_LIST + valueFrom: + componentVarRef: + compDef: clickhouse-keeper-22 + optional: false + podFQDNs: Required runtime: securityContext: fsGroup: 1001 @@ -22,8 +86,8 @@ spec: type: RuntimeDefault containers: - name: clickhouse - image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository | default "bitnami/clickhouse" }}:{{ default .Chart.AppVersion .Values.image.tag }} imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} + image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository | default "bitnami/clickhouse" }}:{{ default .Chart.AppVersion .Values.image.tag }} securityContext: allowPrivilegeEscalation: false capabilities: @@ -91,50 +155,4 @@ spec: - name: config mountPath: /bitnami/clickhouse/etc/conf.d/default - name: user-config - mountPath: /bitnami/clickhouse/etc/users.d/default - vars: - - name: CLICKHOUSE_ADMIN_USER - value: admin - - name: CLICKHOUSE_ADMIN_PASSWORD - valueFrom: - credentialVarRef: - name: admin - optional: false - password: Required - volumes: - - name: data - services: - - name: default - spec: - ports: - - name: http - targetPort: http - port: 8123 - - name: tcp - targetPort: tcp - port: 9000 - - name: tcp-mysql - targetPort: tcp-mysql - port: 9004 - - name: tcp-postgresql - targetPort: tcp-postgresql - port: 9005 - - name: http-intersrv - targetPort: http-intersrv - port: 9009 - - name: http-metrics - targetPort: http-metrics - port: 8001 - configs: - - name: clickhouse-tpl - templateRef: clickhouse-tpl - volumeName: config - namespace: {{ .Release.Namespace }} - - name: clickhouse-user-tpl - templateRef: clickhouse-user-tpl - volumeName: user-config - namespace: {{ .Release.Namespace }} - constraintRef: clickhouse-constraints - systemAccounts: - - name: admin - initAccount: true + mountPath: /bitnami/clickhouse/etc/users.d/default \ No newline at end of file diff --git a/addons/clickhouse/templates/cmpd-keeper.yaml b/addons/clickhouse/templates/cmpd-keeper.yaml index 36d9d6bc7..fd1c2a396 100644 --- a/addons/clickhouse/templates/cmpd-keeper.yaml +++ b/addons/clickhouse/templates/cmpd-keeper.yaml @@ -1,7 +1,7 @@ apiVersion: apps.kubeblocks.io/v1alpha1 kind: ComponentDefinition metadata: - name: clickhouse-keeper-{{ .Chart.Version }} + name: clickhouse-keeper-22 labels: {{- include "clickhouse.labels" . | nindent 4 }} {{- if .Values.commonLabels }} @@ -13,8 +13,46 @@ metadata: spec: provider: ApeCloud description: {{ .Chart.Description }} - serviceKind: {{ .Chart.Name }} - serviceVersion: {{ .Chart.AppVersion }} + serviceKind: clickhouse-keeper + serviceVersion: 22.9.4 + services: + - name: default + spec: + ports: + - name: tcp + targetPort: tcp + port: 2181 + - name: http-metrics + targetPort: http-metrics + port: 8001 + logConfigs: + {{- range $name, $pattern := .Values.logConfigs }} + - name: {{ $name }} + filePathPattern: {{ $pattern }} + {{- end }} + exporter: + scrapePath: /metrics + scrapePort: "8001" + configs: + - name: clickhouse-keeper-tpl + templateRef: clickhouse-keeper-tpl + volumeName: config + namespace: {{ .Release.Namespace }} + systemAccounts: + - name: admin + initAccount: true + vars: + - name: CLICKHOUSE_ADMIN_PASSWORD + valueFrom: + credentialVarRef: + name: admin + optional: false + password: Required + - name: CH_KEEPER_POD_FQDN_LIST + valueFrom: + componentVarRef: + optional: false + podFQDNs: Required runtime: securityContext: fsGroup: 1001 @@ -22,8 +60,8 @@ spec: type: RuntimeDefault containers: - name: clickhouse - image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository | default "bitnami/clickhouse" }}:{{ default .Chart.AppVersion .Values.image.tag }} imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} + image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository | default "bitnami/clickhouse" }}:{{ default .Chart.AppVersion .Values.image.tag }} securityContext: allowPrivilegeEscalation: false capabilities: @@ -46,36 +84,27 @@ spec: - name: tcp containerPort: 2181 - name: raft - containerPort: 9444 + containerPort: 9181 - name: http-metrics containerPort: 8001 + # livenessProbe: + # failureThreshold: 6 + # initialDelaySeconds: 30 + # periodSeconds: 10 + # successThreshold: 1 + # timeoutSeconds: 5 + # exec: + # command: ['/bin/bash', '-c', 'echo "ruok" | timeout 2 nc -w 2 localhost 2181 | grep imok'] + # readinessProbe: + # failureThreshold: 6 + # initialDelaySeconds: 5 + # periodSeconds: 10 + # successThreshold: 1 + # timeoutSeconds: 5 + # exec: + # command: ['/bin/bash', '-c', 'echo "ruok" | timeout 2 nc -w 2 localhost 2181 | grep imok'] volumeMounts: - name: data mountPath: /bitnami/clickhouse - name: config - mountPath: /bitnami/clickhouse/etc/conf.d/default - vars: - - name: CLICKHOUSE_ADMIN_PASSWORD - valueFrom: - credentialVarRef: - compDef: clickhouse - name: admin - optional: false - password: Required - volumes: - - name: data - services: - - name: default - spec: - ports: - - name: tcp - targetPort: tcp - port: 2181 - - name: http-metrics - targetPort: http-metrics - port: 8001 - configs: - - name: clickhouse-keeper-tpl - templateRef: clickhouse-keeper-tpl - volumeName: config - namespace: {{ .Release.Namespace }} \ No newline at end of file + mountPath: /bitnami/clickhouse/etc/conf.d/default \ No newline at end of file diff --git a/addons/clickhouse/templates/cmpv.yaml b/addons/clickhouse/templates/cmpv.yaml new file mode 100644 index 000000000..6d34f8dba --- /dev/null +++ b/addons/clickhouse/templates/cmpv.yaml @@ -0,0 +1,27 @@ +apiVersion: apps.kubeblocks.io/v1alpha1 +kind: ComponentVersion +metadata: + name: clickhouse-cluster + labels: + {{- include "clickhouse.labels" . | nindent 4 }} + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} + {{- end }} + {{- if .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} + {{- end }} +spec: + compatibilityRules: + - releases: + - 22.9.4 + compDefs: + - clickhouse-22 + - releases: + - 22.9.4 + compDefs: + - clickhouse-keeper-22 + releases: + - name: 22.9.4 + serviceVersion: 22.9.4 + images: + clickhouse: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository | default "bitnami/clickhouse" }}:{{ default .Chart.AppVersion .Values.image.tag }} \ No newline at end of file diff --git a/addons/clickhouse/values.yaml b/addons/clickhouse/values.yaml index c2dd2f496..7597349e9 100644 --- a/addons/clickhouse/values.yaml +++ b/addons/clickhouse/values.yaml @@ -9,6 +9,8 @@ fullnameOverride: "" ## commonLabels: {} +logConfigs: {} + commonAnnotations: {} image: