Skip to content

Install on Kubernetes

Kubernetes needs two pieces:

  1. ClickHouse must write system.opentelemetry_span_log and expose a read-only monitoring user.
  2. Click-Dog must run in exactly one supported topology: a sidecar in every ClickHouse pod, or one cluster-mode Deployment that reads the cluster.

For full coverage, run a sidecar in every ClickHouse pod, pointed at localhost. The shipped generator creates a Deployment instead, in cluster mode when you pass --cluster. It is quicker to install, but it reads one replica per shard, so on a replicated cluster it misses spans. See Choose the topology.

Prerequisites

  • a Kubernetes cluster and kubectl
  • a ClickHouse Service reachable from the Click-Dog namespace
  • permission to configure ClickHouse and create its monitoring user
  • an OTLP/gRPC receiver address
  • either a local click-dog binary, or Docker for the installer-wrapper generator

If ClickHouse is managed by the Altinity operator, install its ClickHouseInstallation CRD before applying the example below:

kubectl apply -f https://raw.githubusercontent.com/Altinity/clickhouse-operator/master/deploy/operator/clickhouse-operator-install-bundle.yaml

1. Enable the ClickHouse span log

Click-Dog only reads telemetry; it cannot make ClickHouse emit it. Every ClickHouse pod that should contribute traces must define system.opentelemetry_span_log.

With the Altinity operator, add this to the ClickHouseInstallation:

apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
metadata:
  name: clickhouse
  namespace: clickhouse
spec:
  configuration:
    files:
      config.d/opentelemetry.xml: |
        <clickhouse>
            <opentelemetry_span_log>
                <engine>
                    ENGINE = MergeTree
                    PARTITION BY toYYYYMM(finish_date)
                    ORDER BY (finish_date, finish_time_us, trace_id)
                </engine>
                <database>system</database>
                <table>opentelemetry_span_log</table>
                <flush_interval_milliseconds>7500</flush_interval_milliseconds>
            </opentelemetry_span_log>
        </clickhouse>

The operator puts the file on every pod and performs the required rolling restart. ClickHouse only starts writing the table after restart.

Span generation must also be sampled. ClickHouse emits spans for queries with a parent trace context, or you can temporarily set opentelemetry_start_trace_probability to 1 while validating the pipeline and lower it afterward.

The complete checked-in example is deploy/kubernetes/clickhouse-operator-spanlog.yaml.

2. Create the read-only monitoring user

Click-Dog needs SELECT on two system tables and enforces readonly=2 on every connection. With the Altinity operator, extend the same installation:

spec:
  configuration:
    profiles:
      click_dog_readonly/readonly: 2
    users:
      click_dog_monitor/networks/ip:
        - "::/0" # tighten to the Click-Dog pod CIDR in production
      click_dog_monitor/password_sha256_hex: REPLACE_WITH_SHA256_HEX_OF_PASSWORD
      click_dog_monitor/profile: click_dog_readonly
      click_dog_monitor/quota: default
      click_dog_monitor/grants/query:
        - "GRANT SELECT ON system.opentelemetry_span_log TO click_dog_monitor"
        - "GRANT SELECT ON system.query_log TO click_dog_monitor"
        # The cluster-mode Deployment reads through cluster(), a table function
        # ClickHouse gates behind REMOTE; system.columns feeds the replica
        # capability probes. A sidecar needs only the two SELECTs.
        - "GRANT REMOTE ON *.* TO click_dog_monitor"
        - "GRANT SELECT ON system.columns TO click_dog_monitor"

Generate the password hash while keeping the plaintext for the Click-Dog Secret:

printf '%s' 'YOUR_PASSWORD' | sha256sum | awk '{print $1}'

If you do not use the operator, execute equivalent SQL through your existing secured ClickHouse administration path:

CREATE USER IF NOT EXISTS click_dog_monitor IDENTIFIED WITH sha256_hash BY '<hash>';
GRANT SELECT ON system.opentelemetry_span_log TO click_dog_monitor;
GRANT SELECT ON system.query_log TO click_dog_monitor;
-- Cluster-mode Deployment (cluster() reads) only; a sidecar needs just the two SELECTs.
GRANT REMOTE ON *.* TO click_dog_monitor;
GRANT SELECT ON system.columns TO click_dog_monitor;

Run the grants on every ClickHouse node (ON CLUSTER where the user is managed through SQL). Without REMOTE the cluster-mode Deployment fails every read with Not enough privileges ... READ ON REMOTE, and click-dog check names the missing grant. See Configuration · Cluster Mode for the full set.

Administrator credentials are needed only to create the user. Never put them in the Click-Dog runtime Secret.

3. Choose the topology

Run one Click-Dog in every ClickHouse pod, pointed at localhost. That is the sidecar topology: each pod's span log is read once, by its own sidecar, and nothing needs coordinating. Use the cluster-mode Deployment only when you cannot add a container to the ClickHouse pods, or on a small cluster where a container per pod is overkill and the replica warning below does not apply. Configuration · Choose a topology compares the two.

Sidecar in the ClickHouse pod

One Click-Dog container runs inside each ClickHouse pod, connects to localhost, and keeps use_cluster_queries: false. Because it shares the ClickHouse pod's network namespace, it reads only that pod's local span log. The generator does not create it: add it to the pod template as shown in the sidecar example.

Cluster-mode Deployment

One Click-Dog Deployment reaches ClickHouse through its Service and uses ClickHouse cluster() queries, which read one replica per shard:

clickhouse:
  host: clickhouse.clickhouse.svc.cluster.local
  port: 9000
  use_cluster_queries: true
  cluster: main

use_cluster_queries: true requires a non-empty cluster name. Validation fails instead of silently falling back to one Service-routed pod. A single-node ClickHouse installation can omit --cluster; the generator warns that the Deployment will then read only the pod selected by the Service.

On a replicated cluster, the Deployment misses spans

The span log is not replicated: each ClickHouse pod records only the queries it ran. Each cluster() read takes one replica per shard, so spans on the other replicas are missed by that read. Coverage is partial, can vary between cycles, can split traces, and raises no error. The Deployment covers every pod only when --cluster names a remote_servers definition in which every pod is its own shard; with that layout, any one unreachable pod fails every read. Otherwise, use sidecars.

Do not combine sidecars with cluster queries

A sidecar on every pod with use_cluster_queries: true makes every instance a whole-cluster reader. Unless they all share one Keeper election, each exports the same spans, multiplying exports and cluster load. Use either one cluster-mode Deployment or sidecars that read only their own pod.

A standalone Deployment or DaemonSet cannot use localhost: that address points back to the Click-Dog container's own pod. The Kubernetes generator therefore rejects loopback --ch-host values.

4. Generate the cluster-mode Deployment

Export the monitoring password and point the generator at the ClickHouse Service and OTLP receiver:

export CLICKHOUSE_PASSWORD="your-monitoring-password"
click-dog deploy kubernetes \
  -c otel-collector.monitoring:4317 \
  --otel-secure=false \
  --ch-host clickhouse.clickhouse.svc.cluster.local \
  --cluster main

On a fresh workstation, the release installer can run the same generator from the published image:

curl -fsSL https://github.com/coltconsulting/click-dog/releases/latest/download/install.sh -o install.sh
export CLICKHOUSE_PASSWORD="your-monitoring-password"
bash install.sh kubernetes \
  -c otel-collector.monitoring:4317 \
  --otel-secure=false \
  --ch-host clickhouse.clickhouse.svc.cluster.local \
  --cluster main

The wrapper requires Docker but generates files only; it does not install a host binary or systemd service. It runs the image as your user, or as root in the container under rootless Docker, so the generated files, including the 0600 secret.yaml, belong to you.

The generator cannot reach the cluster's network, so it does not guess the OTLP transport. A collector that is not in the same pod needs --otel-secure=true or --otel-secure=false; without either, the command refuses before writing anything, naming both values and noting that in-cluster collectors usually serve plaintext. The examples above pass --otel-secure=false for an OpenTelemetry Collector or Datadog Agent whose OTLP receiver has no TLS configured. Pass --otel-secure=true (or bare --otel-secure) when the receiver speaks TLS: the ConfigMap then sets secure: true under exporters.otel, and click-dog verifies the receiver against the image's system trust store. Write the value with =; --otel-secure false is refused, pointing to --otel-secure=false. A collector container in the same pod (localhost:4317) needs no flag: the ConfigMap gets a comment stating the rule instead of a secure key, and plaintext is chosen automatically (OTLP transport).

Neither command tests the handshake, because -c names the receiver as the cluster resolves it. install.sh kubernetes passes --otel-secure to the generator only when you give it; run on a terminal without it, it asks which transport the in-cluster collector serves, unless the collector is loopback.

For a collector on a private CA, or one that requires a client certificate, the generated Deployment mounts two optional sources read-only at /etc/click-dog/tls/. The pod starts without either:

File Source Config field
ca.pem key ca.pem of ConfigMap click-dog-otel-ca ca_cert
client.crt, client.key keys tls.crt, tls.key of Secret click-dog-otel-client client_cert, client_key
kubectl -n click-dog create configmap click-dog-otel-ca \
  --from-file=ca.pem=/secure/pki/otel-collector-ca.pem
kubectl -n click-dog create secret tls click-dog-otel-client \
  --cert=click-dog-client.crt --key=click-dog-client.key

Then set the matching fields under exporters.otel in configmap.yaml (--otel-secure=true writes them there commented out). Set a field only once its source exists, because click-dog will not start with a TLS file it cannot read. The client key is mounted 0440 and group-owned by the pod's fsGroup, so only click-dog can read it. Field reference: Configuration: TLS.

Both paths create click-dog-k8s/ containing a Namespace, ServiceAccount, ConfigMap, Secret, single-replica Deployment, .gitignore, and kustomization.yaml. The Secret contains credentials and is written locally with mode 0600; do not commit it.

Review the generated YAML, then apply it:

kubectl apply -k click-dog-k8s/

The ConfigMap enables health on :8686 and Prometheus metrics on :9090. The Deployment probes /healthz for liveness and /readyz for readiness.

The pod runs Click-Dog as user and group 65532, with a read-only root filesystem and every capability dropped. Its fsGroup: 65532 makes Secret and ConfigMap volumes, including the TLS sources above, group-owned by 65532; anything else you mount must be readable by that user or group. deploy/kubernetes/deployment.yaml sets the same identity.

5. Verify

Check the workload, then run Click-Dog's own data-path check:

kubectl get pods -n click-dog -o wide
kubectl logs -n click-dog deploy/click-dog --tail=50
kubectl exec -n click-dog deploy/click-dog -- \
  click-dog check --config /etc/click-dog/click-dog.yaml

Confirm ClickHouse is writing spans and the monitoring user can read them:

EXISTS TABLE system.opentelemetry_span_log;
SELECT count()
FROM system.opentelemetry_span_log
WHERE finish_date >= today();

A non-zero count after traced queries confirms the source is filling. If it stays at zero, verify sampling and confirm the ClickHouse pods restarted after the span-log configuration landed.

Update

Resolve a stable release, update only the generated image reference, then reapply:

LATEST_URL="$(curl -fsSL -o /dev/null -w '%{url_effective}' \
  https://github.com/coltconsulting/click-dog/releases/latest)" || exit 1
VERSION="${LATEST_URL##*/v}"

click-dog deploy kubernetes --update -v "$VERSION" -o click-dog-k8s
kubectl apply -k click-dog-k8s/

The command creates deployment.yaml.bak and changes only the image tag. It does not rewrite the ConfigMap or Secret, and it does not pick up other changes to the generated Deployment. When the changelog lists one, such as runAsGroup: 65532 in the pod securityContext, edit deployment.yaml to match or regenerate the directory. The equivalent installer-wrapper command is:

bash install.sh kubernetes update -v "$VERSION" -o click-dog-k8s

See Updating for the shared config-default and prerelease contract.

Migrating an old DaemonSet output directory

Output generated before the generator switched to a Deployment contains daemonset.yaml. The update command refuses it because changing an image tag cannot migrate topology. Regenerate the directory with the current generator, apply it, then delete the old DaemonSet—kubectl apply -k does not prune the obsolete workload:

kubectl delete daemonset click-dog -n click-dog

Sidecar example

When ClickHouse runs as a StatefulSet or operator-managed pod, add a Click-Dog container to that pod template:

- name: click-dog
  image: ghcr.io/coltconsulting/click-dog:${VERSION}
  securityContext:
    runAsNonRoot: true
    runAsUser: 65532
    runAsGroup: 65532
    allowPrivilegeEscalation: false
    readOnlyRootFilesystem: true
    capabilities:
      drop: [ALL]
    seccompProfile:
      type: RuntimeDefault
  args: ["--config", "/etc/click-dog/click-dog.yaml"]
  env:
    - name: CLICKHOUSE_USERNAME
      valueFrom:
        secretKeyRef:
          name: click-dog-secret
          key: CLICKHOUSE_USERNAME
    - name: CLICKHOUSE_PASSWORD
      valueFrom:
        secretKeyRef:
          name: click-dog-secret
          key: CLICKHOUSE_PASSWORD
  resources:
    requests: { cpu: 50m, memory: 64Mi }
    limits: { cpu: 200m, memory: 128Mi }
  volumeMounts:
    - name: click-dog-config
      mountPath: /etc/click-dog
      readOnly: true

The mounted config must use clickhouse.host: localhost and use_cluster_queries: false. Pin ${VERSION} to the bare release version in the rendered manifest rather than using latest in production.

The container's securityContext runs Click-Dog as user and group 65532, with the cluster-mode Deployment's restrictions, whatever user the ClickHouse pod sets. It applies to this container only, so the ClickHouse container keeps the pod's settings, and a pod fsGroup, if the pod sets one, still applies to both.

OTLP TLS

The shipped deploy/kubernetes/configmap.yaml sets secure: true for its placeholder collector. Click-Dog then verifies the collector's server certificate against the image's system trust roots, which is all a collector with a publicly trusted certificate needs. An in-cluster OpenTelemetry Collector or Datadog Agent (including one reached through $(DD_AGENT_HOST)) serves plaintext on 4317 unless its OTLP TLS is configured; set secure: false for it, as the ConfigMap's comment says. Leaving secure out gives TLS for any collector not in the same pod, so an omitted key is not a way to get plaintext (OTLP transport).

For a collector on a private CA, or one that requires clients to present a certificate, deploy/kubernetes/deployment.yaml mounts two optional sources at /etc/click-dog/tls/:

File Source Config field
ca.pem key ca.pem of ConfigMap click-dog-otel-ca ca_cert
client.crt, client.key keys tls.crt, tls.key of Secret click-dog-otel-client client_cert, client_key

Create the ConfigMap from the CA that signed the collector's server certificate:

kubectl -n click-dog create configmap click-dog-otel-ca \
  --from-file=ca.pem=/secure/pki/otel-collector-ca.pem

For mutual TLS, deploy/kubernetes/certificate.yaml has cert-manager run a private CA in the namespace and issue Click-Dog a client certificate into click-dog-otel-client. Apply it, then export the CA certificate for the collector:

kubectl apply -f deploy/kubernetes/certificate.yaml
kubectl -n click-dog wait --for=condition=Ready certificate/click-dog-otel-client
kubectl -n click-dog get secret click-dog-otel-client-ca \
  -o jsonpath='{.data.tls\.crt}' | base64 -d > click-dog-client-ca.pem

Configure the collector to trust click-dog-client-ca.pem for client certificates; the OpenTelemetry Collector's OTLP receiver reads it from tls.client_ca_file. The CA lasts ten years; export it again if cert-manager ever renews it.

The example keeps the CA's private key in the click-dog namespace, so anyone who can read Secrets there can mint client certificates the collector trusts. In production, keep the CA outside that namespace, for example behind a ClusterIssuer whose CA Secret lives in the cert-manager namespace: delete the bootstrap issuer, root certificate, and CA issuer from the file, and name that issuer in click-dog-otel-client's issuerRef. Do the same to issue from a CA you already run. A client certificate from outside cert-manager works too: create click-dog-otel-client as a kubernetes.io/tls Secret.

Then enable the fields whose source exists:

exporters:
  otel:
    - collector_address: otel-collector.monitoring:4317
      secure: true
      ca_cert: /etc/click-dog/tls/ca.pem          # click-dog-otel-ca
      client_cert: /etc/click-dog/tls/client.crt  # click-dog-otel-client
      client_key: /etc/click-dog/tls/client.key

Both sources are optional, so the pod starts without them, but Click-Dog will not start with a TLS file it cannot read: a configured path whose ConfigMap or Secret is missing stops it with an error naming that path.

client.key is mounted with mode 0440, readable only through the pod's fsGroup: 65532. Manifests from click-dog deploy kubernetes mount the same two sources with the same fsGroup. The sidecar example above mounts neither; copy the otel-tls volume and its mount from deploy/kubernetes/deployment.yaml, together with the fsGroup. A ClickHouse pod that already sets an fsGroup works as it is. Do not add one to a ClickHouse pod that has none, because fsGroup also changes the ownership of ClickHouse's volumes; drop mode: 0440 from the copied volume instead.

cert-manager renews the client certificate 30 days before it expires, and the kubelet swaps the new pair into the mounted volume. Click-Dog re-reads client.crt and client.key each time it opens a connection to the collector, so a renewal needs no restart. ca.pem is read once at startup: after changing click-dog-otel-ca, restart Click-Dog (kubectl -n click-dog rollout restart deploy/click-dog).

Give client certificates the TLS Web Client Authentication extended key usage; in cert-manager, list client auth under usages, as certificate.yaml does. Let's Encrypt stopped issuing it in 2026, and collectors built on Go's TLS stack, including the OpenTelemetry Collector, reject a client certificate whose extended key usage leaves it out, so issue client certificates from your own CA. For the same reason certificate.yaml no longer requests a Let's Encrypt certificate; see the changelog. Field reference: OTEL Exporter.

Migrate from click-dog-otel-tls

Earlier versions of deploy/kubernetes/deployment.yaml mounted Secret click-dog-otel-tls at /etc/click-dog/tls/, so configurations named tls.crt, tls.key, and ca.crt there. The Deployment no longer mounts that Secret, and Click-Dog stops on TLS files it cannot read. If such a setup works today, for example because you replaced the Let's Encrypt issuer with a CA issuer, move it before applying the new Deployment:

  1. Put the client certificate in click-dog-otel-client. With cert-manager, set your Certificate's secretName to click-dog-otel-client and wait for it to be Ready. Otherwise create it from the files: kubectl -n click-dog create secret tls click-dog-otel-client --cert=client.crt --key=client.key.
  2. If you set ca_cert, create click-dog-otel-ca from the CA that signed the collector's server certificate, as above. When one CA signed both certificates, that is the old Secret's ca.crt.
  3. In configmap.yaml, change client_cert, client_key, and ca_cert to /etc/click-dog/tls/client.crt, client.key, and ca.pem.
  4. Apply the ConfigMap and the Deployment together:

    kubectl apply -f deploy/kubernetes/configmap.yaml -f deploy/kubernetes/deployment.yaml
    
  5. Once the new pod is ready, delete click-dog-otel-tls, the Certificate that wrote it, and any Let's Encrypt ClusterIssuers nothing else uses.

Managed ClickHouse

ClickHouse Cloud and other managed offerings often do not permit config.d/ files, so the span-log settings above do not apply. Sampling has to be set on the application's user or role instead, where the provider allows it.

On providers that expose no span log at all, the live path has nothing to read; the historical query-log backfill path may still be available, as a separate source and mode.

Check the provider's current settings and system-table support before deploying. Where SQL user management is available, keep the monitoring grants restricted to whichever required system tables the service exposes.

ClickHouse Cloud is a separate case. It does expose system.opentelemetry_span_log, and is not supported yet for a different reason. See ClickHouse Cloud.

Remove

Remove the generated Kubernetes resources with their orchestrator:

kubectl delete -k click-dog-k8s/

Retain or remove the local generated directory and Secret according to your configuration-management policy. click-dog deploy uninstall is systemd-only and deliberately does not alter Kubernetes resources.