Skip to content

Commit

Permalink
Add CHK to provision keeper (#11)
Browse files Browse the repository at this point in the history
* add CHK to provision keeper

* addressing reviews
  • Loading branch information
denisok authored Feb 10, 2025
1 parent 9a8b219 commit 28a16af
Show file tree
Hide file tree
Showing 11 changed files with 336 additions and 29 deletions.
9 changes: 3 additions & 6 deletions charts/clickhouse/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
dependencies:
- name: clickhouse-keeper-sts
repository: https://helm.altinity.com
version: 0.1.5
- name: altinity-clickhouse-operator
repository: https://docs.altinity.com/clickhouse-operator
version: 0.23.6
digest: sha256:939229b2beb0f969689638b7b7dcd581cbe3f6561052a5328b46e72986fe346d
generated: "2024-12-02T13:25:33.014013-05:00"
version: 0.24.3
digest: sha256:b94131a88dd2045295643ffb85cd0c84c723e86c0513df7308c527e19ee80cc2
generated: "2025-01-28T13:19:50.741222228+01:00"
11 changes: 3 additions & 8 deletions charts/clickhouse/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ apiVersion: v2
name: clickhouse
description: A Helm chart for creating a ClickHouse® Cluster with the Altinity Operator for ClickHouse
type: application
version: 0.1.7
appVersion: "23.8.8.21"
version: 0.2.0
appVersion: "24.3.12.76"

dependencies:
- name: clickhouse-keeper-sts
repository: https://helm.altinity.com
version: 0.1.5
alias: keeper
condition: keeper.enabled
- name: altinity-clickhouse-operator
repository: https://docs.altinity.com/clickhouse-operator
version: 0.23.6
version: 0.24.3
alias: operator
condition: operator.enabled
22 changes: 18 additions & 4 deletions charts/clickhouse/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ A Helm chart for creating a ClickHouse Cluster with the Altinity Operator for Cl

| Repository | Name | Version |
|------------|------|---------|
| https://docs.altinity.com/clickhouse-operator | operator(altinity-clickhouse-operator) | 0.23.6 |
| https://helm.altinity.com | keeper(clickhouse-keeper-sts) | 0.1.3 |
| https://docs.altinity.com/clickhouse-operator | operator(altinity-clickhouse-operator) | 0.24.3 |

## Installing the Chart

Expand All @@ -20,7 +19,7 @@ A Helm chart for creating a ClickHouse Cluster with the Altinity Operator for Cl
helm repo add kubernetes-blueprints-for-clickhouse https://altinity.github.io/kubernetes-blueprints-for-clickhouse

# use this command to install clickhouse chart (it will also create a `clickhouse` namespace)
helm install ch kubernetes-blueprints-for-clickhouse/clickhouse --namespace clickhouse --create-namespace
helm install --create-namespace --namespace clickhouse eks-dev --set keeper.enabled=true --set clickhouse.replicasCount=2
```

> Use `-f` flag to override default values: `helm install -f newvalues.yaml`
Expand Down Expand Up @@ -65,7 +64,7 @@ kubectl exec -it chi-eks-dev-0-0-0 --namespace clickhouse -- clickhouse-client
| clickhouse.defaultUser.password | string | `""` | |
| clickhouse.image.pullPolicy | string | `"IfNotPresent"` | |
| clickhouse.image.repository | string | `"altinity/clickhouse-server"` | |
| clickhouse.image.tag | string | `"23.8.8.21.altinitystable"` | Override the image tag for a specific version |
| clickhouse.image.tag | string | `"24.3.12.76.altinitystable"` | Override the image tag for a specific version |
| clickhouse.keeper | object | `{"host":"","port":2181}` | Keeper connection settings for ClickHouse instances. |
| clickhouse.keeper.host | string | `""` | Specify a keeper host. Should be left empty if `clickhouse-keeper.enabled` is `true`. Will override the defaults set from `clickhouse-keeper.enabled`. |
| clickhouse.keeper.port | int | `2181` | Override the default keeper port |
Expand All @@ -80,7 +79,22 @@ kubectl exec -it chi-eks-dev-0-0-0 --namespace clickhouse -- clickhouse-client
| clickhouse.podLabels | object | `{}` | |
| clickhouse.replicasCount | int | `1` | number of replicas. If greater than 1, keeper must be enabled or a keeper host should be provided under clickhouse.keeper.host. Will be ignored if `zones` is set. |
| clickhouse.service.type | string | `"ClusterIP"` | |
| clickhouse.service.lbService.enable | bool | `false` | additional cluster LB service |
| clickhouse.service.lbService.serviceAnnotations | object | `""` | annotations for the LB service |
| clickhouse.zones | list | `[]` | |
| keeper.enabled | bool | `false` | Whether to enable Keeper. Required for replicated tables. |
| keeper.replicaCount | int | `3` | Number of keeper replicas. Must be an odd number. !! DO NOT CHANGE AFTER INITIAL DEPLOYMENT |
| keeper.image | string | `"altinity/clickhouse-keeper"` | |
| keeper.tag | string | `"24.3.12.76.altinitystable"` | |
| keeper.settings | object | `[]` | `clickhouse-keeper` global config, for example: `prometheus/port: "7000"` |
| keeper.localStorage.size | string | `"5Gi"` | size for keeper PV |
| keeper.localStorage.storageClass | string | `""` | storage class for keeper PV |
| keeper.nodeSelector | object | `{}` | |
| keeper.tolerations | object | `{}` | |
| keeper.zoneSpread | bool | `false` | topologySpreadConstraints over `zone`, by deafult there is only podAntiAffinity by hostname |
| keeper.metricsPort | string | `""` | add metrics port to the service and pod |
| keeper.resources.cpuRequestsMs | string | `"250m"` | |
| keeper.resources.memoryRequestsMiB | string | `"128Mi"` | |
| keeper.resources.cpuLimitsMs | string | `"500m"` | |
| keeper.resources.memoryLimitsMiB | string | `"128Mi"` | |
| operator.enabled | bool | `true` | Whether to enabled the Altinity Operator for ClickHouse. Disable if you already have the Operator installed cluster-wide. |
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
clickhouse:
antiAffinity: true
replicasCount: 3
lbService:
enabled: true
serviceAnnotations:
minikube.io/lb: "internal"
nodeSelector:
node.kubernetes.io/instance-type: "minikube-node"
persistence:
enabled: true
size: 5Gi
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
clickhouse-keeper.altinity.com/cluster: chk-test

keeper:
enabled: true
replicaCount: 3
zoneSpread: true
localStorage:
size: 1Gi
metricsPort: 7000
settings:
prometheus/endpoint: /metrics
prometheus/port: 7000
prometheus/metrics: true
prometheus/events: true
prometheus/asynchronous_metrics: true
prometheus/status_info: true
podAnnotations:
prometheus.io/port: "7000"
prometheus.io/scrape: "true"
resources:
cpuRequestsMs: "250m"
memoryRequestsMiB: "128Mi"
cpuLimitsMs: "500m"
memoryLimitsMiB: "128Mi"
35 changes: 35 additions & 0 deletions charts/clickhouse/examples/values-production-2zones-3replicas.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
clickhouse:
antiAffinity: true
replicasCount: 3
nodeSelector:
node.kubernetes.io/instance-type: "m7i.large"
persistence:
enabled: true
size: 50Gi
storageClass: gp3-encrypted
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
clickhouse-keeper.altinity.com/cluster: chk-test

keeper:
enabled: true
replicaCount: 3
zoneSpread: true
localStorage:
size: 5Gi
storageClass: gp3-encrypted
metricsPort: 7000
settings:
prometheus/endpoint: /metrics
prometheus/port: 7000
prometheus/metrics: true
prometheus/events: true
prometheus/asynchronous_metrics: true
prometheus/status_info: true
podAnnotations:
prometheus.io/port: "7000"
prometheus.io/scrape: "true"
21 changes: 20 additions & 1 deletion charts/clickhouse/examples/values-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,27 @@ clickhouse:
- us-west-2a
- us-west-2b
nodeSelector:
node.kubernetes.io/instance-type: "m6i.large"
node.kubernetes.io/instance-type: "m7i.large"
persistence:
enabled: true
size: 50Gi
storageClass: gp3-encrypted

keeper:
enabled: true
replicaCount: 3
zoneSpread: true
localStorage:
size: 5Gi
storageClass: gp3-encrypted
metricsPort: 7000
settings:
prometheus/endpoint: /metrics
prometheus/port: 7000
prometheus/metrics: true
prometheus/events: true
prometheus/asynchronous_metrics: true
prometheus/status_info: true
podAnnotations:
prometheus.io/port: "7000"
prometheus.io/scrape: "true"
6 changes: 5 additions & 1 deletion charts/clickhouse/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ Pod Template Base
tolerations:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.clickhouse.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end -}}

{{/*
Expand Down Expand Up @@ -164,7 +168,7 @@ Keeper Host
{{ .Values.clickhouse.keeper.host }}
{{- else -}}
{{- if .Values.keeper.enabled -}}
{{- include "clickhouse-keeper.fullname" (dict "Chart" (index .Subcharts "keeper" "Chart") "Release" .Release "Values" (index .Values "keeper")) -}}
{{- printf "keeper-%s" (include "clickhouse.fullname" .) | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- else -}}
{{- end -}}
{{- end -}}
Expand Down
14 changes: 10 additions & 4 deletions charts/clickhouse/templates/chi.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- $service_name := tpl (include "clickhouse.serviceTemplateName" . ) . -}}
---
apiVersion: "clickhouse.altinity.com/v1"
kind: ClickHouseInstallation
Expand All @@ -8,13 +9,19 @@ metadata:
spec:
defaults:
templates:
serviceTemplate: {{ include "clickhouse.serviceTemplateName" . }}
serviceTemplate: {{ $service_name }}
{{- if .Values.clickhouse.lbService.enabled }}
clusterServiceTemplate: {{ $service_name }}-lb
{{- end }}
podTemplate: {{ include "clickhouse.podTemplateName" . }}
{{- if .Values.clickhouse.persistence.enabled }}
dataVolumeClaimTemplate: {{ include "clickhouse.volumeClaimTemplateName" . }}
{{- end }}
useTemplates:
- name: {{ include "clickhouse.serviceTemplateName" . }}
- name: {{ $service_name }}
{{- if .Values.clickhouse.lbService.enabled }}
- name: {{ $service_name }}-lb
{{- end }}
- name: {{ include "clickhouse.podTemplateName" . }}
- name: {{ include "clickhouse.volumeClaimTemplateName" . }}
{{- if not (empty .Values.clickhouse.zones) -}}
Expand All @@ -23,7 +30,6 @@ spec:
- name: {{ include "clickhouse.podTemplateName" $originalContext }}-{{ . }}
{{- end -}}
{{- end }}

configuration:
users:
default/networks/ip: {{ include "clickhouse.defaultUser.ip" . | quote }}
Expand Down Expand Up @@ -53,7 +59,7 @@ spec:
zookeeper:
nodes:
- host: {{ $keeper_host }}
port: {{ .Values.keeper.port }}
port: {{ .Values.clickhouse.keeper.port }}
{{- end }}

{{ include "validate.clickhouse.keeper" . }}
47 changes: 44 additions & 3 deletions charts/clickhouse/templates/chit-service.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{{- $service_name := tpl (include "clickhouse.serviceTemplateName" . ) . -}}
---
apiVersion: "clickhouse.altinity.com/v1"
kind: ClickHouseInstallationTemplate
metadata:
name: {{ include "clickhouse.serviceTemplateName" . }}
name: {{ $service_name }}
labels:
{{- include "clickhouse.labels" . | nindent 4 }}
spec:
templates:
serviceTemplates:
- name: {{ include "clickhouse.serviceTemplateName" . }}
- name: "{{ $service_name }}"
metadata:
{{- with .Values.podAnnotations }}
{{- with .Values.clickhouse.service.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 12 }}
{{- end }}
Expand All @@ -19,6 +20,9 @@ spec:
{{- with .Values.podLabels }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.clickhouse.service.serviceLabels }}
{{- toYaml . | nindent 10 }}
{{- end }}
spec:
type: {{ .Values.clickhouse.service.type }}
ports:
Expand All @@ -30,3 +34,40 @@ spec:
targetPort: 9000
selector:
{{- include "clickhouse.selectorLabels" . | nindent 12 }}
{{- if .Values.clickhouse.lbService.enabled }}
---
apiVersion: "clickhouse.altinity.com/v1"
kind: ClickHouseInstallationTemplate
metadata:
name: "{{ $service_name }}-lb"
labels:
{{- include "clickhouse.labels" . | nindent 4 }}
spec:
templates:
serviceTemplates:
- name: "{{ $service_name }}-lb"
metadata:
labels:
{{- include "clickhouse.labels" . | nindent 12 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.clickhouse.lbService.serviceLabels }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.clickhouse.lbService.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 12 }}
{{- end }}
spec:
type: "LoadBalancer"
ports:
- name: http
port: 8123
targetPort: 8123
- name: tcp
port: 9000
targetPort: 9000
selector:
{{- include "clickhouse.selectorLabels" . | nindent 12 }}
{{- end }}
Loading

0 comments on commit 28a16af

Please sign in to comment.