Tidemark

Configuration

Tidemark is configured with environment variables, and in Kubernetes the Helm chart sets them from its values. This chapter goes by task: what you want Tidemark to do, the keys for it, and an example. Every key with its default and the variable it sets is in Reference; the examples show only what changes.

Connect to Kafka

Beside Strimzi, kafka.strimzi.clusterName is all it takes: the bootstrap service, TLS with the cluster CA, a KafkaUser with its certificate (Installation). Any other cluster is named by its bootstrap servers, with TLS and authentication in the shape of Strimzi’s client authentication, and any other client property under its own name in kafka.config:

clusterName: payments-prod
kafka:
  bootstrapServers: kafka-0.example.internal:9093,kafka-1.example.internal:9093
  tls:
    enabled: true
    caCertificate: {secretName: kafka-ca, key: ca.crt}
  config:
    client.dns.lookup: use_all_dns_ips

The cluster name is part of every manifest’s key, tidemark/<cluster>/manifests/…; beside Strimzi it defaults to the Kafka resource’s name. Pick one per cluster and keep it: a new name starts a new prefix, and the old manifests are no longer the newest.

At start Tidemark compares the cluster’s topic IDs with the newest manifest in its prefix. If not one of them exists on the cluster, the prefix belongs to an earlier incarnation, typically the cluster a restore came from, and Tidemark refuses to start rather than write manifests of the wrong cluster on top. The fix is a new bucket or container for the new cluster. A cluster whose topics were all recreated on purpose takes a new bucket or container as well.

The rights the principal needs are in Installation.

Store manifests

Set exactly one of storage.s3.bucket and storage.azure.container; the chart refuses both, because the one that lost would be the one somebody looks in. On a laptop, without the chart, TIDEMARK_MANIFEST_DIR is the third store (Outside Kubernetes).

S3 and S3-compatible

An S3-compatible store with its own CA:

storage:
  s3:
    bucket: tidemark
    endpoint: https://objects.example.internal
    region: us-east-1
    caCertificate: {configMapName: s3-ca, key: ca.crt}
Azure Blob Storage

With workload identity:

storage:
  azure:
    container: tidemark
    endpoint: https://exampletidemark.blob.core.windows.net
    workloadIdentity:
      clientId: 00000000-0000-0000-0000-000000000000

Tidemark never deletes a manifest. A lifecycle rule on the store does, after manifestRetentionDays; Tidemark only publishes that number, so the alerts can warn before the restore point expires. Keep the two equal. A longer retention costs storage and buys time: when the backup falls further behind than the retention, the newest covered manifest is deleted and there is no restore point at all.

Measure coverage against Kannika

A manifest is a restore point only once the backup holds every record below its cut. With any of them set, Tidemark reads Kannika’s segment index for every topic in the cut and publishes the recovery point, tidemark_restore_point_age_seconds. Without one, the manifests are written all the same and nobody tells you which of them the backup has reached.

Where the index lies Tidemark reads from Kannika’s own resources, the Storage the backup writes to and the Credentials with its keys:

backup:
  kannika:
    namespace: kannika-system
    storage: prod-archive
    credentials: prod-archive-credentials
    credentialsSecrets: [prod-archive-keys]   # the Secret the Credentials point at

The chart grants get on exactly these, in Kannika’s namespace. Every location key set by hand wins over what the Storage says, and without a Storage they are the whole location:

backup:
  kannika:
    prefix: prod/
    s3:
      bucket: kannika-backup
      credentials: {secretName: kannika-s3, accessKey: access-key, secretKey: secret-key}

The prefix is the Kannika storage’s directory; the index of a topic is at <prefix><topic>/index. Each backup.kannika.s3.* key left empty falls back to its storage.s3.* counterpart, so a backup in Tidemark’s own bucket needs only the provider and the prefix. On Azure the managed identity needs Storage Blob Data Reader on Kannika’s account if it is another one.

Where the archive ends a little below a cut, Tidemark reads the source in between, read_committed and without a consumer group. No record there means the partition ends on a commit marker and is covered exactly; the verdict is stored beside the manifest, so a restore after a total loss judges it the same way. This needs Read on the topics in the cut. Each refresh spends at most ten seconds on it.

Check: tidemark_restore_point_age_seconds{class="clean"} appears within a few refreshes and stays close to tidemark_manifest_age_seconds{class="clean"}. The gap between the two is the backup’s lag.

Leave topics out of the cut

Some topics nobody needs back: topics whose source fills them again anyway, such as market data or a cache rebuilt at start. An excluded topic is not in the cut, needs no backup, and never holds the recovery point back. The manifest still keeps its definition, so a restore recreates it, empty.

They are named in the restore policy, YAML files in ConfigMaps of your own that the chart mounts as one directory, by name or by a pattern that matches the whole topic name:

apiVersion: v1
kind: ConfigMap
metadata:
  name: tidemark-restore-policy
data:
  topics.yaml: |
    topics:
      - pattern: market-data\..*
        backup: exclude

with restorePolicy.configMaps: [tidemark-restore-policy] in the values. k8s/restore-policy.yaml in the repository is a commented example.

Check the pattern against the topic list before installing it:

kafka-topics.sh --bootstrap-server <bootstrap> --list | grep -E '^market-data\..*$'
Warning
Never exclude Kafka Streams internal topics (-changelog, -repartition). They carry records a restore needs.

The same files declare the topics Kafka Connect keeps its positions in (connect-offsets: true) and the defaults of a restore, and a KafkaTopic label ranks with them where Tidemark runs in a pod and knows the Kafka cluster. Several ConfigMaps can share the directory, one per team for instance. Beside Strimzi the labels on the KafkaTopic and KafkaUser resources count as well, and rank with a file’s entry for the same name. Tidemark reads the files again once a cadence, and a change applies from the next round on, without a restart.

Every topic under topicPrefix (_tidemark. by default), the canary’s and the restore’s state topic, is always left out and needs no entry. So is each of those three topics set by its full name (canary.topics.in, canary.topics.out, stateTopic), which ignores the prefix. tidemark_excluded_topics counts what the newest manifest leaves out.

Tune the round

Cadence. A round every 10 seconds means a restore point every 10 seconds. That is the granularity of restore points, not the RPO: what a restore loses is set by the slowest backup partition, however often Tidemark cuts. A shorter cadence writes more manifests (8,640 a day at 10 seconds) and buys little.

Everything else about the round Tidemark settles itself: how a large leader’s cut is spread over several connections, how long a round waits before it judges its transactions, how much of a partition it reads to find a transaction the cut falls through. Which partition holds a topic back is on the page, not in a setting.

Logging. log.level sets Tidemark’s level, log.kafkaLevel the Kafka clients' separately, because the clients are the loud ones at DEBUG. Raise the second only when the question is about the broker.

Look at the manifests

Keys

ui.enabled.

The page at /, on the same port as /metrics, shows the newest manifest, the rounds behind it, the restore point, and one manifest read out in words. It reads and never writes, and it is on by default. It puts topic, partition and group names on that port, which is no more than a manifest in the bucket carries; ui.enabled: false turns it off. The chart has no Ingress for it:

kubectl -n kafka port-forward svc/tidemark 8080
# then open http://localhost:8080/

Restore mode

A restore is led by a second Tidemark, in restore mode, pointed at the target cluster and reading the lost cluster’s manifests. It takes no rounds, runs no canary and writes no manifests. On the target it writes only its state topic, the log of every decision the restore takes, and, if you allow it, the commands a human asks it to run. How the restore goes is in During the disaster; this is what to prepare. It is the same chart, as a release of its own:

clusterName: payments-prod          # the lost cluster's, as in the manifest keys
kafka:
  strimzi:
    clusterName: payments-new       # the target
storage:
  s3:
    bucket: tidemark                # the lost cluster's store
backup:
  kannika:
    namespace: kannika-system
restore:
  enabled: true
  execute: false
  kannika:
    resource:
      name: payments-restore
      storage: prod-archive
      eventhub: payments-new

clusterName and the store are the lost cluster’s, because restore mode reads its manifests from that prefix. The Kafka connection is the target’s. The archive the page checks coverage against is the Storage the Restore resource reads from (restore.kannika.resource.storage), unless backup.kannika names another or a bucket of Kannika’s. The target’s own normal Tidemark, installed later, needs a new bucket: its topics are a new incarnation.

restore.execute: true lets the page run its commands itself (create topics, alter configs, create ACLs, set group offsets) where the restore principal has the rights, and records each in the state topic. With false the page shows the commands for a human to run. Whatever the principal may not do stays a command on the page.

Beside Strimzi the chart creates the restore principal as a KafkaUser: Describe, DescribeConfigs and Read on the topics, Write on the state topic, Describe on the groups and the cluster, and with restore.execute also Create and Alter on the cluster, AlterConfigs on the topics and Read on the groups. Elsewhere grant the same, and read access to the object store. Tidemark does not create the state topic on its own; it logs the command:

kafka-topics.sh --bootstrap-server <target> --create --topic _tidemark.restore \
    --partitions 1 --config retention.ms=-1 --config cleanup.policy=delete

Check: /health answers 200 as soon as the endpoints are up, even before the target exists, because choosing a manifest needs only the store. tidemark_restore_state_ready turns 1 once the state topic has been read back.