All posts
Manage ClickHouse on Kubernetes with CHOps Insights

Manage ClickHouse on Kubernetes with CHOps Insights

November 24, 202621 min readMohamed Hussain S
Share:

The problem nobody warns you about

Running ClickHouse on Kubernetes through an operator feels great on day one. You apply one YAML file, the operator creates the pods, volumes, services and config, and queries start flowing.

Then day thirty arrives. A pod says Running, but is it actually receiving queries? A disk is at 82% full, but can it even be expanded? ClickHouse lists four replicas, Kubernetes built five. A host restarted at 3 a.m. and you have no idea what it printed before it died.

You have two tools for this. kubectl tells you what Kubernetes believes. A SQL client tells you what ClickHouse believes. Neither tells you when the two disagree, and that disagreement is where most production incidents hide.

That gap is what the Kubernetes support in CHOps, the open-source GUI and admin tool for ClickHouse, is built to close. In this post we will connect a Kubernetes-hosted ClickHouse cluster to CHOps, walk through all eleven Kubernetes Insights tabs, and look at the small details that make them useful in a real incident.

What CHOps supports on Kubernetes

CHOps manages ClickHouse over its HTTP interface, so it works with almost any deployment. The Kubernetes integration goes one step further for clusters managed by a Kubernetes operator:

Where your ClickHouse runsHow you connect in CHOpsKubernetes Insights
Kubernetes + Altinity® operator (AKOC)Kubernetes tabYes
Kubernetes + official ClickHouse operator (OCKO)Kubernetes tabYes (early access)
Kubernetes with no operatorDirect connectionNo
Bare metal, VM, DockerDirect connectionNo
ClickHouse Cloud, Altinity.Cloud (hosted), other managed servicesDirect connectionNo
Altinity.Cloud BYOK (cluster in your own cloud account)Kubernetes tabYes

Hosted managed services do not expose a Kubernetes API to you, so there is nothing for CHOps to read there. That is not a gap: you still get every other CHOps feature through a direct connection. The exception is Altinity.Cloud BYOK: the cluster runs in your own cloud account and you have access to it, so it behaves like any other Kubernetes cluster.

When you do connect through the Kubernetes tab, two things happen. You pick your installation from a list instead of typing host names, and the host list stays correct as the cluster scales up or down.

The one idea that explains most setup problems

CHOps runs outside your Kubernetes cluster, and it makes two separate connections:

ConnectionUsed forNeeds
Kubernetes APIReading hosts, storage, events, logsAPI address, CA certificate, token
ClickHouseQueries, dashboards, alertsA reachable address, user, password

They are independent, so one can work while the other fails, and CHOps reports them separately on purpose.

The catch: inside the cluster, ClickHouse lives at addresses like chi-demo-main-0-0-0.demo.svc.cluster.local. Those names mean nothing from outside. So even when CHOps can read your cluster perfectly, it still needs an externally reachable address for ClickHouse itself. This is the step most people miss, and we will handle it explicitly below.

Setting it up in four steps

Budget about 20 minutes the first time. You will need kubectl pointed at the right cluster, permission to create service accounts and roles, a running operator with at least one installation (kubectl get chi -A for AKOC), and CHOps running with an administrator login. CHOps currently supports ClickHouse 26.3 LTS and 26.8 LTS.

Not sure which operator you have? Check the CRDs:

kubectl get crd | grep -i clickhouse

Seeing clickhouseinstallations.clickhouse.altinity.com means AKOC. Seeing clickhouseclusters.clickhouse.com means OCKO. Both can coexist in one cluster.

Step 1: Create a read-only identity

CHOps ships a helper script that creates a dedicated, read-only service account. It prints everything it is about to create and waits for your confirmation before touching anything.

chmod +x scripts/chops-k8s-setup.sh
./scripts/chops-k8s-setup.sh

It creates a chops namespace, a chops-reader service account, a ClusterRole with binding, and a token secret. The account can read installations (including Keeper), pods, pod logs, services, config maps, events, volume claims, endpoint slices, stateful sets, network policies, ingresses, disruption budgets and pod metrics, plus namespaces, storage classes and nodes (cluster-wide access only). It cannot create, update, patch or delete anything (its one write, a SelfSubjectRulesReview, only asks Kubernetes what the token may do), and it cannot read Kubernetes Secrets. Kubernetes enforces that, not CHOps.

The script finishes by printing three values: the API address, the CA certificate, and a token. CHOps always verifies the CA certificate, and there is no switch to turn that off.

Prefer a narrower scope? Limit it to specific namespaces:

./scripts/chops-k8s-setup.sh -n production -n staging

The trade-off: CHOps then cannot list namespaces (you type the name instead), cannot check volume expansion capability, and cannot read node labels for zone awareness.

Want CHOps to read the operator's own logs as well? Pass the namespace where the operator pod runs with -o:

./scripts/chops-k8s-setup.sh -o <operator-namespace>

This adds read access to the operator pod and its logs. You will enter the same namespace later in the wizard.

Setup script confirmation prompt in the terminal

Before moving on, verify the three values with a quick curl. If this fails, nothing later will work:

curl --cacert /tmp/ca.crt \
  -H "Authorization: Bearer $(cat /tmp/token.txt)" \
  https://<api-address>/apis/clickhouse.altinity.com/v1/namespaces/<your-namespace>/clickhouseinstallations

You are looking for JSON containing ClickHouseInstallationList.

Step 2: Make ClickHouse reachable from outside

This is the second connection from earlier. Your options, from quick to production-grade:

  • Port-forward for testing only: kubectl port-forward -n <ns> service/clickhouse-<installation> 8123:8123. Close the terminal and the cluster disappears.
  • LoadBalancer service via an operator service template. Convenient, but remember you are putting a database on a network, so lock it down with firewall rules, security groups or ClickHouse user network restrictions.
  • Internal load balancer (recommended): same idea, but the address is private and CHOps runs inside that network.
  • Ingress, if you already run an ingress controller.

Step 3: Create a dedicated ClickHouse user

Do not use the default user. The operator restricts default to the cluster's own pod IPs, so a connection from CHOps is refused, and the refusal looks exactly like a wrong password. People lose a lot of time double-checking a password that was always correct. Leave the clickhouse_operator user alone as well.

Add a user for CHOps in your installation spec:

spec:
  configuration:
    users:
      chops/password: use-a-real-password-here
      chops/networks/ip: "::/0"   # narrow this to CHOps address in production
      chops/profile: default
      chops/quota: default

For production, store a SHA-256 hash with chops/password_sha256_hex instead of a plain password, and restrict networks/ip to the single address CHOps runs from.

One more grant to know about: the cluster-wide views in Kubernetes Insights use clusterAllReplicas(), so if your server checks grants for table functions, the CHOps user also needs REMOTE. The clickhouse-user-setup.sql script grants SELECT, SHOW, KILL QUERY, INTROSPECTION, BACKUP, ACCESS MANAGEMENT, ALTER INDEX and ALTER PROJECTION, but not REMOTE or S3, so add REMOTE yourself.

Step 4: Add the cluster in CHOps

Go to Control panel → Cluster Management → Kubernetes tab → New Cluster. A four-step wizard follows:

  1. Connect. Paste the whole block the script printed into the large paste box. CHOps extracts the three values itself. Name the connection and click Test connection. You want to see a "Connected" result, and if a permission is missing CHOps names the exact one. Then click Continue.
  2. Operator and installation. Pick AKOC or OCKO (pre-selected if only one is installed), choose a namespace, click Find installations, and select yours.
  3. ClickHouse address. Enter the externally reachable address from Step 2, the port (the default is 8443) and whether TLS is on. This step also has a Pod addressing setting, explained in the warning section below.
  4. Credentials. Enter the user from Step 3 once for the whole installation. Every host inherits it, which is what keeps things working when someone scales the cluster and new hosts appear.

Two details on the Connect step:

  • Operator namespace (optional) tells CHOps where the operator pod runs so it can read the operator's own logs. The Altinity operator installs into kube-system by default, while OCKO usually runs in its own namespace. The Probe button next to the field checks that CHOps can find the operator pod. It works only after the connection is saved, and the token needs the -o grant.
  • If you created the token with -n, Test connection can fail because that token cannot list namespaces. That is expected: click Continue and type the namespace in step 2.

CHOps tests the credentials before saving and tells you which half failed if something is wrong. Adding the cluster anyway is a reasonable choice: the Kubernetes screens will still work, which is exactly what you need while diagnosing why ClickHouse will not answer.

CHOps Kubernetes wizard, step 1 of 4: Connect
CHOps Kubernetes wizard, step 2 of 4: Installation
CHOps Kubernetes wizard, step 3 of 4: ClickHouse address
CHOps Kubernetes wizard, step 4 of 4: Credentials

A warning you might see: "Per-node data will not be accurate for this cluster." CHOps shows this when it cannot reach the individual pods. Every query then goes to the single address you entered, so the per-node screens (Current Queries, Merges, Parts and Replication) show one arbitrary pod, possibly a different one on each refresh. Cluster-wide queries in the SQL editor are not affected.

This is controlled by Pod addressing in step 3 of the wizard. Auto-detect (recommended) tries each pod's internal address, then a NodePort or LoadBalancer service per pod, and falls back to the single address. Always connect to pods directly skips the check, which helps when a network policy blocks the check but real traffic works. Always use the address above sends every query to the one address.

If CHOps runs outside the cluster, internal pod addresses do not resolve. Give each pod its own service (Auto-detect shows an AKOC example) or run CHOps inside the cluster, which is the simplest option. Click Import anyway to continue without per-node accuracy, or Cancel to fix it first.

Per-node data warning dialog in CHOps

To confirm it worked: the cluster should appear with the right number of hosts, SELECT hostName(), version() should run from the SQL editor, and alerts and dashboards should work against it with no Kubernetes-specific setup. That last point is the whole design goal: Kubernetes is just another way to find hosts.

A tour of the eleven Kubernetes Insights tabs

Open Overview → Kubernetes Insights (administrators only). You will see eleven tabs: Health, Topology, Reconcile, Rollout, Keeper, Storage, Resources, Network, Configuration, Events and Logs. Each tab shows a "read at" timestamp, and if a read fails you get a clear red banner with a Retry button rather than silently stale data.

Health: open this one first

Ten plain-language checks, summarised as something like "6 of 8 passing, 2 could not run":

  • Operator reachable
  • All hosts ready
  • All hosts in rotation (actually receiving queries)
  • No version skew between hosts
  • Health signals trustworthy (operator troubleshoot mode is off)
  • Protected against node drains (a pod disruption budget exists)
  • No stalled volume expansion
  • Data survives a scale-down
  • Memory limits set on every pod
  • Replicas spread across availability zones

Two design choices are worth calling out. First, a check can read unknown when CHOps cannot determine the answer (for example, the token cannot read nodes), and unknown results are excluded from the count. Reporting a false failure, or a false all-clear, would be worse than admitting uncertainty. Second, a failing check is not an outage. These are the things that turn into incidents later, when someone drains a node or a disk fills up.

Do not be alarmed if a fresh AKOC install shows two failures (no disruption budget, volumes deleted on scale-down). Those are honest answers about default settings. The Memory limits check also fails if the installation sets no memory limit. On OCKO, the first two typically pass because that operator creates budgets per shard and retains volumes.

A Copy report button gives you a plain-text PASS/FAIL/UNKNOWN list to paste into a ticket or chat.

Kubernetes Insights Health tab

Topology: the shape of your cluster

A shard is a slice of your data, a replica is a copy of a shard, and a pod is one ClickHouse server. So 2 shards × 2 replicas means 4 pods.

Each box shows the pod name, readiness, whether it is in rotation, and its restart count with the last stop reason. The key insight is that ready and in rotation are different things. A pod can be Running and perfectly healthy while absent from the service that receives queries. ClickHouse looks fine, but for your users that host is doing nothing, and almost nothing else will show you this.

Banners flag the dangerous patterns: troubleshoot mode on, mixed versions after a half-finished upgrade, two replicas sharing one node or one availability zone, and a missing pod disruption budget.

Kubernetes Insights Topology tab

Reconcile: what the operator is doing

To reconcile means making reality match your installation description. On AKOC you get status, task ID, host counts, and a Replica readiness table, which is the most useful part after scaling: a new replica must create its tables and copy existing data before it does its share of work. Without this table you would poll system.replicas by hand.

On OCKO, CHOps shows the Ready condition reason, and a scale is complete when three conditions line up: Ready (every shard has a ready replica), ClusterSizeAligned (running replicas match the requested topology), and SchemaInSync (databases exist everywhere). CHOps surfaces the first; use kubectl describe for the other two.

Banners catch the sneaky cases: an installation nobody is reconciling (the operator watches other namespaces), a deliberately paused reconcile, a stopped installation, and an unreachable operator, where queries keep working but nothing you change is applied.

Rollout: did the last change actually finish?

A table of StatefulSets showing desired, current, ready and updated counts, the revision, and a status of complete, in progress or stuck. "Stuck" is flagged when a pod is waiting on something that will not fix itself, such as CrashLoopBackOff or ImagePullBackOff, and a red banner names the pod and the reason.

Note for OCKO users: Rollout matching has been verified on a live OCKO cluster with one installation per namespace. If you run installations whose names share a prefix, check that Rollout lists only the expected StatefulSets.

Keeper: the replication lifeline

Replicated tables need Keeper to accept writes. This tab shows Keeper sessions per host (address, uptime, connected or expired), replicated-table counts with how many are read-only, and the Keeper hosts from your installation. The headline banner is read-only tables: when a Keeper session is lost, writes to those tables fail right now. It reads system.zookeeper_connection and system.replicas on every replica, and on a cluster without replication the sessions panel simply does not appear.

Storage: capacity joined with real free space

Kubernetes knows how big a volume is. ClickHouse knows how full it is. Neither is useful alone. This tab joins them: requested vs actual size, storage class, whether it can grow, and whether a resize is in flight.

The Resize column hides a real trap. A state like NodeResizePending looks finished and is not: the control plane is done, but the node is not, and with many storage drivers the pod must be restarted to finish. Someone grows a disk during an emergency, sees no error, assumes it worked, and goes home. CHOps raises this at the top of the screen, and flags failed expansions too, since they do not retry on their own.

For free space, CHOps uses the DiskUsed metric from system.asynchronous_metric_log over the last 7 days to estimate growth per day and time until full, and warns when a disk will fill within 14 days. (It needs at least an hour of history.) Note that "cannot grow" is the correct answer on K3s, minikube and kind, whose default storage cannot expand.

Kubernetes Insights Storage tab

Resources: requests, limits and real usage

Per-pod CPU and memory requests and limits from the spec, plus ClickHouse's own MemoryTracking metric as a percentage of the memory limit, plus live usage from the Kubernetes metrics API (this needs metrics-server and read access to pod metrics). Two banners matter most: pods without a memory limit, which can consume an entire node's memory, and max_server_memory_usage set larger than the container limit, which lets ClickHouse try to use memory the container does not have, ending in an OOM kill.

Network: three views that should agree

The most valuable feature here is the three-way check. There are three independent descriptions of the same cluster: what your installation says should exist, what ClickHouse has in its own remote_servers configuration, and what is actually routable right now. CHOps flags hosts that are configured but not in ClickHouse (a reconcile has not propagated) and hosts that are in ClickHouse but not routable (queries sent there will fail). If the check cannot run, it says so instead of showing a false all-clear.

The tab also lists services (type, external address, ports), network policies, and disruption budgets. If a connection times out even though your credentials are right, a network policy is very often the culprit, and the symptom looks just like a wrong address.

Configuration: written vs running

YAML, because that is what you write and what kubectl prints. On AKOC you see two panels: Written (what you submitted) and Running (after operator templates were merged in). They usually differ, and that is expected. This screen exists because "why is my setting not taking effect?" nearly always has its answer here. On OCKO the Running panel is empty because that operator does no template merging.

Anything password-shaped is redacted on the server before it reaches your browser.

Events: what Kubernetes recorded

Recent events for the installation, newest first, with warnings in bold and repeat counts like "(3 times)" that usually mean something is retrying and failing. You can filter to warnings only, auto-reload every 30 seconds, and click a pod name to jump straight to that pod's logs. When a pod will not start, the message here almost always names the actual problem.

Logs: the Previous container switch

Pick a pod, set the number of lines, and read what ClickHouse printed. The most important control is Previous container. When a pod crashes, Kubernetes starts a fresh container, and a normal log read shows that new, nearly empty one. That is why log viewing feels useless exactly when you need it. Flip on Previous container and you read the one that died, which is where the error lives. CHOps even prompts you when the selected pod has restarted.

Combined with the termination reason on the Topology tab, that is a complete crash diagnosis: why it stopped, and what it said right before.

Search is case-insensitive and filters what is already fetched (no re-read), a context-lines option keeps stack traces readable instead of returning only the first line, and a counter like "12 of 1000 lines match" stops you from concluding there were only twelve errors. To read the operator's own logs, run the setup script with -o <operator-namespace> and fill in the Operator namespace on the Connect step. The operator then appears in the same dropdown.

Kubernetes Insights Logs tab

Alerts that fire before the incident

The Health tab includes a Health alerts panel. Turn on "Alert on health check failures", choose one or more notification channels, and save. Under the hood:

  • CHOps runs the checks every 15 minutes, even when nobody has the page open.
  • A check must fail in two consecutive runs before a notification goes out, which filters short blips.
  • You get one failure notification per failure, not a repeating stream, followed by a recovery notification when it passes again.
  • Unknown results send nothing.

Failure notifications are critical severity and recovery notifications are info, both sharing one alert ID, so PagerDuty automatically closes the incident the failure opened. Channels are created under Control panel → Notification Channels, and CHOps supports email, Slack, Teams, Google Chat and PagerDuty.

How the host list stays current

When you scale an operator-managed cluster, you should not have to edit anything in CHOps. The rules:

  • The list is not editable, because the installation is the source of truth and the next refresh would overwrite your changes. Credentials, display name and endpoint remain editable.
  • It refreshes every 15 minutes and whenever you press Refresh. Fifteen minutes is deliberate: the host set only changes when a person scales the cluster.
  • Missing hosts are not removed immediately. With defaults, a host must be unseen for about 45 minutes (15 minutes × 3 missed refreshes), because pods vanish briefly during upgrades and node drains. If the cluster is entirely unreachable, CHOps keeps the previous list and shows the last refresh time.

Both the interval and the missed-refresh count can be changed under Control panel → App Config.

Things that look wrong but are not

A short list worth keeping handy:

  • Storage says volumes cannot grow → correct on K3s, minikube and kind.
  • Two Health failures on a fresh AKOC cluster → correct, they reflect default settings.
  • Written and running configuration differ on AKOC → expected, the operator merges templates.
  • A host vanishes for a minute during a restart → expected, and CHOps deliberately does not react.
  • The operator removed a host after a failed scale-out → that is the operator's default behavior; nobody deleted your machine.
  • Replication monitoring is empty on ClickHouse Cloud → correct, SharedMergeTree has no replication queue.

OCKO: the official operator (early access)

CHOps also supports the official ClickHouse Kubernetes Operator, labelled early access. The reason is straightforward: its custom resources are at v1alpha1, and by Kubernetes convention that means the schema can change without a deprecation cycle. CHOps discovers the served API version rather than hardcoding it, so a version promotion should need no change, but a renamed field would. The two operators describe clusters differently, so CHOps handles each on its own terms, yet the Kubernetes screens look and behave the same whichever you run.

Troubleshooting: three problems you will probably meet

1. Kubernetes screens work, queries fail. The problem is the ClickHouse address or credentials, so revisit Steps 2 and 3. Nine times out of ten it is the default user.

2. Queries work, Kubernetes screens fail. The API address, certificate or token. Check that the address matches your kubeconfig exactly. On managed clouds, check API IP restrictions: if an EKS cluster has public access disabled, CHOps must run inside the VPC, and the same applies to the equivalent private settings on AKS and GKE. Running CHOps on a VM in the same network solves both access problems at once.

3. The certificate does not cover this address. Your certificate is fine, but you are connecting by a name or IP it was not issued for. Use exactly the address from your kubeconfig. On K3s, install with --tls-san <ip> when CHOps lives on another machine.

On any platform, remember CHOps reports the two connections separately, so you can always tell which half failed.

Why this approach is worth it

None of these screens replaces kubectl or SQL. What they do is put the two side by side, so the questions that sit between them become one-click answers: Is that pod actually serving traffic? Did my disk expansion really finish? Why does ClickHouse know about a host Kubernetes does not route to? What did the container print before it died?

And because the Kubernetes integration only changes how hosts are discovered, everything else in CHOps (the SQL editor, query profiler, dashboards, alerts, RBAC and backups) works on these clusters exactly as it does anywhere else.

Try it yourself

ClickHouse® is a registered trademark of ClickHouse, Inc. Altinity® is a registered trademark of Altinity, Inc. Kubernetes® is a registered trademark of The Linux Foundation. CHOps is an independent open-source project and is not affiliated with or endorsed by them.

Share: