Skip to content

Commit

Permalink
chore: migrate api from 0.7 to 0.9 for clickhouse addon
Browse files Browse the repository at this point in the history
  • Loading branch information
sophon-zt committed Sep 5, 2024
1 parent a56e1cc commit 432a5c7
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 101 deletions.
20 changes: 4 additions & 16 deletions addons/clickhouse/configs/00_default_overrides.xml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,25 @@
<!-- Cluster configuration - Any update of the shards and replicas requires helm upgrade -->
<remote_servers>
<default>
{{- range $.cluster.spec.componentSpecs }}
{{ $compIter := . }}
{{- if eq $compIter.componentDefRef "clickhouse" }}
<shard>
{{- $replicas := $compIter.replicas | int }}
{{- range $i, $_e := until $replicas }}
{{- range $_, $host := splitList "," .CLICKHOUSE_POD_FQDN_LIST }}
<replica>
<host>{{ $clusterName }}-{{ $compIter.name }}-{{ $i }}.{{ $clusterName }}-{{ $compIter.name }}-headless.{{ $namespace }}.svc.{{- $.clusterDomain }}</host>
<host>{{ $host }}</host>
<port>9000</port>
</replica>
{{- end }}
</shard>
{{- end }}
{{- end }}
</default>
</remote_servers>
{{- range $.cluster.spec.componentSpecs }}
{{ $compIter := . }}
{{- if or (eq $compIter.componentDefRef "zookeeper") (eq $compIter.componentDefRef "ch-keeper") }}
<!-- Zookeeper configuration -->
<zookeeper>
{{- $replicas := $compIter.replicas | int }}
{{- range $i, $_e := until $replicas }}
{{- range $_, $host := splitList "," .CH_KEEPER_POD_FQDN_LIST }}
<node>
<host>{{ $clusterName }}-{{ $compIter.name }}-{{ $i }}.{{ $clusterName }}-{{ $compIter.name }}-headless.{{ $namespace }}.svc.{{- $.clusterDomain }}</host>
<host>{{ $host }}</host>
<port>2181</port>
</node>
{{- end }}
</zookeeper>
{{- end }}
{{- end }}
<!-- Prometheus metrics -->
<prometheus>
<endpoint>/metrics</endpoint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
<raft_logs_level>warning</raft_logs_level>
</coordination_settings>
<raft_configuration>
{{- $replicas := $.component.replicas | int }}
{{- range $i, $e := until $replicas }}
{{- range $id, $host := splitList "," .CH_KEEPER_POD_FQDN_LIST }}
<server>
<id>{{ $i | int | add1 }}</id>
<hostname>{{ $clusterName }}-{{ $.component.name }}-{{ $i }}.{{ $clusterName }}-{{ $.component.name }}-headless.{{ $namespace }}.svc.{{- $.clusterDomain }}</hostname>
<id>{{ $id | add1 }}</id>
<hostname>{{ $host }}</hostname>
<port from_env="CLICKHOUSE_KEEPER_RAFT_PORT"></port>
</server>
{{- end }}
Expand Down
28 changes: 28 additions & 0 deletions addons/clickhouse/templates/clusterdefinition.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 }}
Expand All @@ -14,16 +14,80 @@ 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
seccompProfile:
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:
Expand Down Expand Up @@ -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
91 changes: 60 additions & 31 deletions addons/clickhouse/templates/cmpd-keeper.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
Expand All @@ -13,17 +13,55 @@ 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
seccompProfile:
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:
Expand All @@ -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 }}
mountPath: /bitnami/clickhouse/etc/conf.d/default
27 changes: 27 additions & 0 deletions addons/clickhouse/templates/cmpv.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 2 additions & 0 deletions addons/clickhouse/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ fullnameOverride: ""
##
commonLabels: {}

logConfigs: {}

commonAnnotations: {}

image:
Expand Down

0 comments on commit 432a5c7

Please sign in to comment.