ClickHouse Operator configuration guide
This guide covers how to configure ClickHouse and Keeper clusters using the operator.ClickHouseCluster configuration
Basic configuration
Replicas and shards
- Replicas: Number of ClickHouse instances per shard (for high availability)
- Shards: Number of horizontal partitions (for scaling)
replicas: 3 and shards: 2 will create 6 ClickHouse pods total.
Keeper integration
Every ClickHouse cluster must reference a KeeperCluster for coordination:keeperClusterRef.namespace is set, the operator must watch both namespaces. If WATCH_NAMESPACE is configured, include the ClickHouse and Keeper namespaces in that list.
KeeperCluster configuration
Storage configuration
Configure persistent storage:Operator can modify existing PVC only if the underlying storage class supports volume expansion.
Pod configuration
Automatic topology spread and affinity
Distribute pods across availability zones:Ensure your Kubernetes cluster has enough nodes in different zones to satisfy the spread constraints.
Manual configuration
Arbitrary pod affinity/anti-affinity rules and topology spread constraints can be specified.See API Reference for all supported Pod template options.
Pod disruption budgets
The operator creates a PodDisruptionBudget (PDB) for each cluster so that voluntary disruptions — node drains, rolling upgrades, autoscaler evictions — cannot take down enough pods to lose quorum or break availability. For ClickHouse clusters with more than one shard, one PDB is created per shard so a disruption in one shard cannot count against another.Defaults
The operator picks safe defaults based on the cluster size so that a freshapply already protects against accidental quorum loss.
| Resource | Topology | Default PDB |
|---|---|---|
ClickHouseCluster | replicas: 1 (single-replica shard) | maxUnavailable: 1 — disruption is allowed for a single-node cluster so that node drains are not blocked |
ClickHouseCluster | replicas: 2+ (multi-replica shard) | minAvailable: 1 — at least one replica per shard must stay up |
KeeperCluster | replicas: 1 | maxUnavailable: 1 — disruption is allowed for a single-node cluster so that node drains are not blocked |
KeeperCluster | replicas: 3+ | maxUnavailable: replicas/2 — preserves the RAFT quorum for a 2F+1 cluster (3 replicas tolerate 1 down, 5 replicas tolerate 2 down) |
replicas: 3, the operator creates three PDBs, one per shard, each with minAvailable: 1.
Overriding the defaults
Usespec.podDisruptionBudget to override either minAvailable or maxUnavailable (exactly one):
maxUnavailable form, with a percentage:
unhealthyPodEvictionPolicy field through to the generated PDB — useful when you need to allow eviction of pods that are still in NotReady:
Policies
spec.podDisruptionBudget.policy lets you choose how aggressively the operator manages PDBs:
| Policy | Behavior |
|---|---|
Enabled (default) | The operator creates and updates the PDB on every reconcile. This is the safe production default. |
Disabled | The operator does not create PDBs and deletes any existing ones with matching labels. Useful for development clusters where every voluntary disruption should be allowed. |
Ignored | The operator neither creates nor deletes PDBs. Existing PDBs are left alone. Use this when another system (e.g. policy admission, GitOps tool) owns PDB management for you. |
Cluster-wide opt-out
PDB management can also be disabled cluster-wide via the operator’sENABLE_PDB environment variable. With ENABLE_PDB=false, the operator skips the PDB reconcile step for every ClickHouseCluster and KeeperCluster regardless of their spec.podDisruptionBudget.policy, and does not watch PodDisruptionBudget resources at all. The operator’s ServiceAccount therefore does not need RBAC permissions on poddisruptionbudgets.policy/v1, which is useful when running the operator under a restricted ServiceAccount that intentionally omits those permissions.
Container configuration
Custom image
Use a specific ClickHouse image:Container resources
Configure CPU and memory for ClickHouse containers:Environment variables
Add custom environment variables:Volume mounts
Add additional volume mounts:It is allowed to specify multiple volume mounts to the same
mountPath.
Operator will create projected volume with all specified mounts.See API Reference for all supported Container template options.
TLS/SSL configuration
Configure secure endpoints
Pass a reference to a Kubernetes Secret containing TLS certificates to enable secure endpointsSSL certificate secret format
It is expected that the Secret contains the following keys:tls.crt- PEM encoded server certificatetls.key- PEM encoded private keyca.crt- PEM encoded CA certificate chain
This format is compatible with cert-manager generated certificates.
ClickHouse-Keeper communication over TLS
If KeeperCluster has TLS enabled, ClickHouseCluster would use secure connection to Keeper nodes automatically. ClickHouseCluster should be able to verify Keeper nodes certificates. If ClickHouseCluster has TLS enabled, is usesca.crt bundle for verification. Otherwise, default CA bundle is used.
User may provide a custom CA bundle reference:
ClickHouse settings
Default user password
Set the default user password:It isn’t recommended to use ConfigMap to store plain text passwords.
Using ConfigMap for user passwords
You can also use ConfigMap for non-sensitive default passwords:Custom users in configuration
Configure additional users in configuration files. Create a ConfigMap and Secret for user:Database sync
Enable automatic database synchronization for new replicas:Custom configuration
Embedded extra configuration
Instead of mounting custom configuration files, you can directly specify additional ClickHouse configuration options. Add custom ClickHouse configuration usingextraConfig:
Useful links:
Embedded extra users configuration
You can also specify additional ClickHouse users configuration usingextraUsersConfig. This is useful for defining users, profiles, quotas, and grants directly in the cluster specification.
The
extraUsersConfig is stored in k8s ConfigMap object. Avoid plain text secrets there.