Tidemark

Installation

Tidemark is one small service per Kafka cluster. It reads the cluster, writes a manifest into object storage every few seconds, and serves metrics. This chapter puts it on Kubernetes with the Helm chart, helm/tidemark in the repository; k8s/ has the same chart rendered for kubectl apply. Each step ends with a way to see that it worked.

What each setting means is in Configuration; every key of the chart is in Reference.

What you need

A Kafka cluster

Tidemark is built and tested against Apache Kafka 4.3 in KRaft mode. It uses the Admin API for topic IDs, DescribeProducers, ListTransactions and the metadata quorum, and reads __consumer_offsets and __transaction_state itself. On a cluster with an authorizer it needs its own principal; the rights are listed below.

A backup that writes to object storage

Tidemark copies no data. A backup tool copies every partition to object storage, and Tidemark writes its manifests beside it. With Kannika as the backup tool, Tidemark also reads the backup’s index and tells you which manifest the backup covers: the recovery point. With any other tool you get the manifests and judge coverage yourself.

Object storage for the manifests

An S3 bucket, an S3-compatible store, or an Azure Blob Storage container. It can be the bucket the backup writes to, under its own prefix. It has to survive the loss of the cluster, because a restore starts from it.

Kubernetes and Helm

Install into the namespace of the Kafka cluster; the examples use kafka. For alerts the Prometheus Operator, for the dashboard Grafana. Strimzi is optional; if the cluster runs on it, the chart creates Tidemark’s KafkaUser and takes the certificates from it.

The chart

The chart is published beside the image, for every build: oci://registry.gitlab.dataflow.academy/kafka/tidemark/charts/tidemark, version 0.0.0-g<commit>. There are no releases yet; the chart’s appVersion is the commit, and so is the image it runs. Everything below goes into one values file, my-values.yaml, and one helm install at the end.

What the chart decides and no value changes:

  • One replica, Recreate. Two Tidemarks writing into the same prefix would interleave their manifests, and "the newest manifest" would stop meaning anything. There is nothing to elect: losing a round costs one cadence. If you do want two, install two releases with their own clusterName or bucket.

  • Probes that do not follow the cluster. The startup and liveness probes ask /live, readiness asks /ready. An outage of Kafka or the store is something Tidemark reports; a restart in the middle of it would only lose the manifests waiting in its buffer.

  • A Service that publishes the pod while it is not ready (publishNotReadyAddresses: true). Tidemark carries no data path, and /health and /metrics are wanted most while it waits for the cluster.

  • No root, a read-only file system, no capabilities. Tidemark writes nothing to disk.

  • No Ingress. The page reads and never writes, and it still shows topic and group names: reach it with kubectl port-forward, or put an Ingress with authentication in front of it yourself.

The resource requests are a starting point, not a measurement: 100m CPU, 512 MiB memory, a 1 GiB limit (resources). Watch the pod for a day on your cluster and adjust.

Step 1: the canary topics

Tidemark measures how fast the fastest application on the cluster could be, by sending its own records through two topics: <prefix>canary.in and <prefix>canary.out, with topicPrefix as prefix (_tidemark. by default). To name one of them in full instead, set canary.topics.in or canary.topics.out; that topic then ignores the prefix. It does not create them, and it does not let the broker auto-create them either, because that would give them one partition. Create both:

for topic in _tidemark.canary.in _tidemark.canary.out; do
  kafka-topics.sh --bootstrap-server <bootstrap> --create --topic "$topic" \
      --partitions <at least one per broker> --replication-factor 3 \
      --config cleanup.policy=delete --config retention.ms=604800000
done

Every broker has to lead at least one partition, or the yardstick is measured on a fraction of the cluster while the cut is judged on all of it. Do not set the replication factor to the broker count: then every probe waits for the slowest broker, and the yardstick rises with the very slowness it should expose.

Do not back these topics up: leave the whole prefix out of the backup. Tidemark always leaves every topic under the prefix out of the cut, and a restore recreates them empty.

Check:

kafka-topics.sh --bootstrap-server <bootstrap> --describe --topic _tidemark.canary.in

shows every broker as a leader of some partition. Without the topics Tidemark starts anyway, logs this command, reports tidemark_canary_topics_missing, and grades every manifest wide until both exist.

Step 2: the object store

Tidemark writes its manifests to S3 or an S3-compatible store, or to Azure Blob Storage. Pick yours; the choice carries over to the other pages.

S3 and S3-compatible

Create a bucket, one per environment. The cluster name is in every key, so several clusters can share it. Then give Tidemark access, in this order of preference:

  1. No key at all. With an instance profile, leave the credentials out; the AWS SDK’s default chain finds them.

  2. No key at all, but workload identity. With IRSA, storage.s3.workloadIdentity.roleArn annotates the ServiceAccount; the role needs s3:ListBucket, s3:GetObject and s3:PutObject.

  3. A key in a Secret, for a store that has no other way in: storage.s3.credentials names the Secret and its two keys.

Tidemark needs to list, read and write objects under tidemark/<cluster>/. It never deletes a manifest. Expire them with a lifecycle rule on the same prefix, as many days as manifestRetentionDays (7):

aws s3api put-bucket-lifecycle-configuration --bucket <bucket> --lifecycle-configuration '{
  "Rules": [{"ID": "tidemark-manifests", "Status": "Enabled",
             "Filter": {"Prefix": "tidemark/<cluster>/"},
             "Expiration": {"Days": 7}}]}'

Limit the rule to that prefix if the backup shares the bucket.

storage:
  s3:
    bucket: tidemark
    endpoint: https://objects.example.internal   # only for an S3-compatible store
    region: us-east-1
    credentials:                                 # only without workload identity
      secretName: tidemark-s3
      accessKey: access-key
      secretKey: secret-key

The region is also the signing region, so it has to match the bucket even on a store that ignores regions. For AWS itself, leave the endpoint out.

A store with its own CA. If the JVM does not trust the store’s certificate, hand Tidemark the CA the way you would hand a Kafka client a truststore. storage.s3.caCertificate takes it from a Secret or a ConfigMap, a PEM by default:

storage:
  s3:
    caCertificate:
      configMapName: s3-ca
      key: ca.crt

A PKCS12 or JKS file takes type and passwordKey as well, and the chart mounts it. The truststore replaces the JVM’s trust for the S3 client alone. It is read once at start, and the log names each certificate it trusts. The certificate still has to name the endpoint’s host.

A store that refuses the SDK’s checksums. Some S3-compatible stores reject the checksum trailer the AWS SDK sends with every upload. Reads work, but every round logs a 403 with "The request signature we calculated does not match". Two SDK variables turn the trailer off:

extraEnvs:
  - {name: AWS_REQUEST_CHECKSUM_CALCULATION, value: when_required}
  - {name: AWS_RESPONSE_CHECKSUM_VALIDATION, value: when_required}

Leave them out for AWS and for stores that accept the default.

Check: from a machine with the same credentials, list the prefix (add --endpoint-url for an S3-compatible store). It is empty now and fills once Tidemark runs:

aws s3 ls s3://<bucket>/tidemark/<cluster>/manifests/ | tail -1
Azure Blob Storage

Blob Storage has no S3 API, so it has a client of its own. With workload identity no storage key exists in the cluster:

storage:
  azure:
    container: tidemark
    endpoint: https://<account>.blob.core.windows.net
    workloadIdentity:
      clientId: <client id of the managed identity>

The chart puts the client ID on the ServiceAccount and the label azure.workload.identity/use on the pod. Outside the chart you need a user-assigned managed identity with Storage Blob Data Contributor on the container, and a federated credential on it naming the cluster’s OIDC issuer and the ServiceAccount, system:serviceaccount:kafka:tidemark for a release called tidemark. Where there is no workload identity, storage.azure.connectionString names a Secret with a connection string instead. Expire manifests with a lifecycle management policy on <container>/tidemark/<cluster>/, as for S3.

Check: from a machine with the same identity, list the prefix. It is empty now and fills once Tidemark runs:

az storage blob list --auth-mode login --account-name <account> --container-name <container> \
  --prefix tidemark/<cluster>/manifests/ --query '[-1].name' -o tsv

Step 3: Kafka access

A cluster without security needs only the bootstrap servers and a name for the manifests. For SCRAM over TLS, for example:

clusterName: payments-prod
kafka:
  bootstrapServers: kafka.example.internal:9093
  tls:
    enabled: true
    caCertificate: {secretName: kafka-ca, key: ca.crt}
  authentication:
    type: scram-sha-512
    username: tidemark
    passwordSecret: {secretName: tidemark-kafka, password: password}

kafka.authentication takes tls, scram-sha-512, scram-sha-256 and plain; anything else goes into kafka.config, which passes every client property on as it is.

What Tidemark needs on a cluster with ACLs

Two rights stop the start when they are missing. Without any of the others Tidemark runs and writes manifests, and what is lost shows in them.

Right For Without it

Read on every topic

the cut, and DescribeProducers for the transactions open at the cut

every manifest says transactions.checked: false and is never atomic; with Describe alone a topic is still cut, without it the topic is in no manifest

DescribeConfigs on every topic

the topic definitions in the manifest

topics without their configuration

Read on __consumer_offsets

the consumer group offsets

Tidemark does not start

Create on __consumer_offsets and __transaction_state

creating them on a fresh cluster

Tidemark does not start on a cluster where they do not exist yet

Read on __transaction_state

the transaction view

no manifest is atomic

Read and Write on both canary topics

the canary’s probes

no yardstick, every partition wide

Describe on the cluster

the ACLs in the manifest, and trusting the group listing

ACLs recorded as not_authorized; the offsets view reads the whole offsets topic

Describe on all groups

starting the offsets view from the Admin API

the view reads __consumer_offsets from the beginning, which can take minutes

Describe on all transactional IDs

starting the transaction view

rounds with a transaction that was already open are not checked

Nothing else: Tidemark joins no group and commits no offsets.

With Strimzi

Name the Kafka resource, and the chart does the rest:

kafka:
  strimzi:
    clusterName: my-cluster

A KafkaUser that exists already takes kafka.strimzi.kafkaUser.create: false and its name; the chart then only mounts its Secret.

It connects to my-cluster-kafka-bootstrap:9093 with TLS and the cluster CA from my-cluster-cluster-ca-cert, creates a KafkaUser named like the release with exactly the rights above, and hands the client certificate from the User Operator’s Secret to the clients. The listener has to authenticate the way the KafkaUser does (kafka.strimzi.kafkaUser.authentication, tls by default), and the Kafka resource needs an authorizer:

spec:
  kafka:
    listeners:
      - name: tls
        port: 9093
        type: internal
        tls: true
        authentication:
          type: tls
    authorization:
      type: simple

The ca.crt in the user’s Secret is the clients CA and does not verify the brokers; the chart takes the cluster CA. The certificates are read once at start, so a renewal needs a restart of the pod. The release has to be in the namespace of the Kafka resource: the KafkaUser’s Secret and the cluster CA are there, and a pod reads Secrets only from its own namespace. The chart also reads the restore policy’s labels from the cluster’s KafkaTopic and KafkaUser resources, with a Role of its own (Leave topics out of the cut).

For restore mode on the target of a restore, the same chart is a second release with restore.enabled; its KafkaUser has the restore principal’s rights.

Step 4: deploy

With the values from the steps above in my-values.yaml:

helm install tidemark oci://registry.gitlab.dataflow.academy/kafka/tidemark/charts/tidemark \
  --version 0.0.0-g<commit> --namespace kafka --values my-values.yaml

The chart refuses at install what Tidemark would refuse at start, and names the key to set. Without Helm, k8s/ in the repository has the chart rendered for a few common cases; apply the one that fits with kubectl -n kafka apply -f, after setting its names and pinning its image.

Check: the rollout finishes, and /health says ok.

kubectl -n kafka rollout status deployment/tidemark
kubectl -n kafka port-forward svc/tidemark 8080 &
curl -s localhost:8080/health

/ready turns 200 once the consumer offsets view has caught up, normally a second or two after start. /health turns 200 once a round was published and a manifest confirmed in the store; before that, and whenever that stops, it answers 503 with the reason. Typical reasons in the log:

  • The cluster does not answer. Tidemark waits rather than exits and logs a "still waiting" line after 1, 3, 7 and 15 minutes. Check the bootstrap address and the listener.

  • A rejected credential or a missing right ends the start with the error.

  • "refusing to start: the manifest prefix … belongs to an earlier incarnation": the prefix holds manifests of a cluster whose topics no longer exist, typically the source of a restore. Use a new bucket; see Configuration.

  • A 403 on writing the manifest: see the checksums above.

A minute later the store holds manifests:

aws s3 ls s3://<bucket>/tidemark/<cluster>/manifests/ | tail -3

Step 5: metrics, alerts and the dashboard

Prometheus scrapes /metrics on the port named http. With the Prometheus Operator, the chart creates the ServiceMonitor, the alerts and the dashboard:

metrics:
  serviceMonitor:
    enabled: true
    labels: {release: prometheus}   # what your Prometheus selects on
  prometheusRule:
    enabled: true
  dashboard:
    enabled: true                   # a ConfigMap for Grafana's sidecar

The alerts fire when the recovery point grows older than half and four fifths of the manifest retention, and when no stored manifest is covered at all. They need a coverage provider (Configuration), because without one Tidemark does not know what the backup covers.

The dashboard is helm/tidemark/files/dashboard.json; without Grafana’s sidecar, import it by hand and pick the Prometheus data source. Its variables are the data source, the cluster and the rate window. It reads top to bottom: is there a restore point, is the cut trustworthy, are the cuts atomic, the cluster through Tidemark’s eyes, Tidemark itself.

Check: in Prometheus,

tidemark_manifest_age_seconds{class="any"}

stays below a few cadences, and tidemark_cut_margin_seconds{leg="chain"} is above zero. The meaning of every series is in Reference.

Next