Skip to main content
Skip to main content
Edit this page

ClickHouse Operator API reference

This document provides detailed API reference for the ClickHouse Operator custom resources.

ClickHouseCluster

ClickHouseCluster is the schema for the ClickHouse cluster API.

API version and Kind

apiVersion: clickhouse.com/v1alpha1
kind: ClickHouseCluster

ClickHouseClusterSpec

ClickHouseClusterSpec defines the desired state of a ClickHouse cluster.

FieldTypeRequiredDefaultDescription
replicas*int32No3Number of replicas in a single shard. Must be >= 0.
shards*int32No1Number of shards in the cluster. Must be >= 0.
keeperClusterRefLocalObjectReferenceYes-Reference to the KeeperCluster used for coordination.
podTemplatePodTemplateSpecNo-Parameters for the pod spec.
containerTemplateContainerTemplateSpecNoSee defaultsParameters for the ClickHouse container spec.
dataVolumeClaimSpecPersistentVolumeClaimSpecYes-Storage configuration for data volumes.
labelsmap[string]stringNo-Additional labels added to all resources.
annotationsmap[string]stringNo-Additional annotations added to all resources.
settingsClickHouseConfigNo-ClickHouse configuration parameters.

Example

apiVersion: clickhouse.com/v1alpha1
kind: ClickHouseCluster
metadata:
  name: example-cluster
spec:
  replicas: 3
  shards: 2
  keeperClusterRef:
    name: example-keeper
  dataVolumeClaimSpec:
    accessModes:
      - ReadWriteOnce
    resources:
      requests:
        storage: 100Gi
  containerTemplate:
    image:
      repository: clickhouse/clickhouse-server
      tag: "25.12"
    resources:
      requests:
        cpu: "2"
        memory: "8Gi"
      limits:
        cpu: "4"
        memory: "16Gi"
  settings:
    defaultUserPassword:
      secret:
        name: clickhouse-password
        key: password
    tls:
      enabled: true
      required: true
      serverCertSecret:
        name: clickhouse-cert

ClickHouseConfig

ClickHouse configuration parameters.

FieldTypeRequiredDefaultDescription
defaultUserPassword*DefaultPasswordSelectorNo-Password for the 'default' user from a Secret or ConfigMap.
loggerLoggerConfigNoSee defaultsLogger configuration.
tlsClusterTLSSpecNo-TLS settings for ClickHouse.
enableDatabaseSyncboolNotrueEnable synchronization of databases to new replicas.
extraConfigruntime.RawExtensionNo-Additional ClickHouse configuration (merged with defaults).
extraUsersConfigruntime.RawExtensionNo-Additional ClickHouse users configuration (merged with defaults).

ClickHouseClusterStatus

ClickHouseClusterStatus defines the observed state of a ClickHouse cluster.

FieldTypeDescription
conditions[]metav1.ConditionCurrent conditions of the cluster.
observedGenerationint64Most recently observed generation.
replicasint32Number of replicas currently running.
readyReplicasint32Number of ready replicas.
configurationRevisionstringTarget configuration revision applied by the operator.
statefulSetRevisionstringTarget StatefulSet controller revision.
currentRevisionstringLast applied cluster spec revision.
updateRevisionstringLast requested cluster spec revision.

KeeperCluster

KeeperCluster is the schema for the ClickHouse Keeper cluster API.

API Version and Kind

apiVersion: clickhouse.com/v1alpha1
kind: KeeperCluster

KeeperClusterSpec

KeeperClusterSpec defines the desired state of a Keeper cluster.

FieldTypeRequiredDefaultDescription
replicas*int32No3Number of replicas. Must be an odd number: 0, 1, 3, 5, 7, 9, 11, 13, or 15.
podTemplatePodTemplateSpecNo-Parameters for the pod spec.
containerTemplateContainerTemplateSpecNoSee defaultsParameters for the Keeper container spec.
dataVolumeClaimSpecPersistentVolumeClaimSpecYes-Storage configuration for data volumes.
labelsmap[string]stringNo-Additional labels added to all resources.
annotationsmap[string]stringNo-Additional annotations added to all resources.
settingsKeeperConfigNo-Keeper configuration parameters.

Example

apiVersion: clickhouse.com/v1alpha1
kind: KeeperCluster
metadata:
  name: example-keeper
spec:
  replicas: 3
  dataVolumeClaimSpec:
    storageClassName: fast-ssd
    accessModes:
      - ReadWriteOnce
    resources:
      requests:
        storage: 10Gi
  containerTemplate:
    resources:
      requests:
        cpu: "500m"
        memory: "512Mi"
      limits:
        cpu: "1"
        memory: "1Gi"
  podTemplate:
    topologyZoneKey: topology.kubernetes.io/zone
  settings:
    tls:
      enabled: true
      required: true
      serverCertSecret:
        name: keeper-cert

KeeperConfig

Keeper configuration parameters.

FieldTypeRequiredDefaultDescription
loggerLoggerConfigNoSee defaultsLogger configuration.
tlsClusterTLSSpecNo-TLS settings for Keeper.
extraConfigruntime.RawExtensionNo-Additional Keeper configuration (merged with defaults).

KeeperClusterStatus

KeeperClusterStatus defines the observed state of a Keeper cluster.

FieldTypeDescription
conditions[]metav1.ConditionCurrent conditions of the cluster.
observedGenerationint64Most recently observed generation.
replicasint32Number of replicas currently running.
readyReplicasint32Number of ready replicas.
configurationRevisionstringTarget configuration revision applied by the operator.
statefulSetRevisionstringTarget StatefulSet controller revision.
currentRevisionstringLast applied cluster spec revision.
updateRevisionstringLast requested cluster spec revision.

Common Types

PodTemplateSpec

Parameters for pod configuration.

FieldTypeRequiredDescription
topologyZoneKeystringNoKubernetes topology key for zone distribution (e.g., topology.kubernetes.io/zone).
nodeHostnameKeystringNoKubernetes label key for node hostname (e.g., kubernetes.io/hostname).
nodeSelectormap[string]stringNoNode selector for pod placement.
affinitycorev1.AffinityNoPod affinity/anti-affinity rules.
tolerations[]corev1.TolerationNoTolerations for tainted nodes.
securityContext*corev1.PodSecurityContextNoPod security context.

Example

podTemplate:
  topologyZoneKey: topology.kubernetes.io/zone
  nodeHostnameKey: kubernetes.io/hostname
  nodeSelector:
    disktype: ssd
  tolerations:
  - key: "dedicated"
    operator: "Equal"
    value: "clickhouse"
    effect: "NoSchedule"
  affinity:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
      - labelSelector:
          matchLabels:
            app.kubernetes.io/name: clickhouse
        topologyKey: kubernetes.io/hostname

ContainerTemplateSpec

Parameters for container configuration.

FieldTypeRequiredDescription
imageContainerImageNoContainer image configuration.
imagePullPolicycorev1.PullPolicyNoImage pull policy (Always, IfNotPresent, Never).
resourcescorev1.ResourceRequirementsNoCPU and memory resource requirements.
env[]corev1.EnvVarNoEnvironment variables.
volumeMounts[]corev1.VolumeMountNoAdditional volume mounts.
securityContext*corev1.SecurityContextNoContainer security context.

Example

containerTemplate:
  image:
    repository: clickhouse/clickhouse-server
    tag: "25.12"
  imagePullPolicy: IfNotPresent
  resources:
    requests:
      cpu: "2"
      memory: "8Gi"
    limits:
      cpu: "4"
      memory: "16Gi"
  env:
  - name: TZ
    value: "UTC"

ContainerImage

Container image specification.

FieldTypeRequiredDefaultDescription
repositorystringNoClickHouse: clickhouse/clickhouse-server
Keeper: clickhouse/clickhouse-keeper
Container image repository.
tagstringNolatestImage tag.

ClusterTLSSpec

TLS configuration for clusters.

FieldTypeRequiredDescription
enabledboolNoEnable TLS.
requiredboolNoRequire TLS for all connections (disables insecure endpoints).
serverCertSecretcorev1.LocalObjectReferenceNoSecret containing server certificate (tls.crt, tls.key).
caBundle*SecretKeySelectorNoSecret containing CA bundle for verification.

Example

tls:
  enabled: true
  required: true
  serverCertSecret:
    name: clickhouse-cert
  caBundle:
    secretKeyRef:
      name: ca-cert-secret
      key: ca.crt

LoggerConfig

Logger configuration for ClickHouse and Keeper.

FieldTypeRequiredDefaultDescription
logToFileboolNotrueWrite logs to file.
levelstringNo"trace"Log level: trace, debug, information, warning, error.
sizestringNo"1000M"Maximum log file size.
countintNo50Number of log files to keep.

Example

logger:
  logToFile: true
  level: "information"
  size: "1000M"
  count: 50

DefaultPasswordSelector

Reference to a Secret or ConfigMap key containing a password.

FieldTypeRequiredDefaultDescription
passwordTypestringNoplaintextType of password encoding. Possible values: plaintext, sha256_password, sha256_hash, double_sha1_password, double_sha1_hash. See ClickHouse documentation for details.
secret*SecretKeySelectorNo-Select password from a Secret key. Mutually exclusive with configMap.
configMap*ConfigMapKeySelectorNo-Select password from a ConfigMap key. Mutually exclusive with secret.
Note

You must specify either secret OR configMap, not both.

Example with Secret (Recommended)

defaultUserPassword:
  passwordType: plaintext  # Optional, default
  secret:
    name: clickhouse-password
    key: password

Example with SHA256

defaultUserPassword:
  passwordType: sha256_password
  secret:
    name: clickhouse-password
    key: password_hash

Example with ConfigMap

defaultUserPassword:
  passwordType: plaintext
  configMap:
    name: clickhouse-config
    key: default_password

Default Values

ClickHouse Defaults

SettingDefault Value
Replicas3
Shards1
Image Repositoryclickhouse/clickhouse-server
Image Taglatest
Image Pull PolicyIfNotPresent
CPU Request2
CPU Limit4
Memory Request4Gi
Memory Limit8Gi
Logger Leveltrace
Logger Log to Filetrue
Logger Size1000M
Logger Count50
Enable Database Synctrue

Keeper Defaults

SettingDefault Value
Replicas3
Image Repositoryclickhouse/clickhouse-keeper
Image Taglatest
Image Pull PolicyIfNotPresent
CPU Request500m
CPU Limit1
Memory Request512Mi
Memory Limit1Gi
Logger Leveltrace
Logger Log to Filetrue
Logger Size1000M
Logger Count50

Conditions

ClickHouseCluster conditions

TypeDescription
SpecValidWhether ClickHouseCluster CustomResource passes validation. Useful in deployments without webhooks
ReconcileSucceededThe success of the last reconciliation cycle
ReplicaStartupSucceededWhether all replicas of the ClickHouseCluster are able to start.
HealthyReadiness of all requested replicas.
ClusterSizeAlignedCluster have the same amount of replicas/shards as requested.
ConfigurationInSyncRepresents Configuration deployment state
ReadyClickHouseCluster is ready to serve client requests. At least one replica in every shard is Ready
SchemaInSyncAll replicas have the same database schema after scaling operations.

KeeperCluster conditions

TypeDescription
SpecValidWhether KeeperCluster CustomResource passes validation. Useful in deployments without webhooks
ReconcileSucceededThe success of the last reconciliation cycle
ReplicaStartupSucceededWhether all replicas of the KeeperCluster are able to start.
HealthyReadiness of all requested replicas.
ClusterSizeAlignedCluster have the same amount of replicas as requested.
ConfigurationInSyncRepresents Configuration deployment state
ReadyKeeperCluster is ready to serve client requests. Leader elected.