Overview
A Backup is used for backing up topics from an EventHub, and offloading them to Storage. It is configured by creating a Backup resource in Kubernetes. The Kannika Armory Operator creates a Deployment that runs the backup process, based on the configuration in the Backup resource.
A Backup can have multiple Backup Streams which are used to configure which topics should be backed up.
Usage
Backups can be managed using the kubectl command line tool,
and are available by the name backup or backups.
$ kubectl get backupsNAME STATUS AGEmy-backup 🚀 Streaming 1sBackup Status
A Backup can have the following statuses:
- Draft The Backup has no streams defined, and is not ready to be started.
- Ready The Backup has streams defined, and is ready to be started.
- Streaming The Backup is running and backing up data to the storage.
- Paused The Backup is paused, and no data is being backed up.
- Failed The Backup has failed, and no data is being backed up.
Configuring a Backup
The following is an example of a Backup.
It configures a Backup which will back up two topics from the my-kafka-cluster EventHub to the my-bucket Storage.
apiVersion: kannika.io/v1alphakind: Backupmetadata: name: backup-examplespec: source: "my-kafka-cluster" sink: "my-storage" streams: - topic: "magic.events" - topic: "pixie.dust"In this example:
-
A Backup named
backup-exampleis created, indicated by the.metadata.namefield. This name will become the basis for the Deployment which is created for this Backup. -
The Backup will connect to the
my-kafka-clusterEventHub to fetch data, indicated by the.spec.sourcefield. The Backup will write data to themy-bucketStorage defined in thespec.sinkfield. -
The
.spec.streamsfield contains a list of Backup Streams. A Backup Stream contains the configuration of each topic that will be backed up. In this case, two topics namedmagic.eventsandpixie.dustwill be backed up.
Automatically importing topics
It is possible to configure a backup so that it automatically adds topics present on a cluster if they match a condition:
apiVersion: kannika.io/v1alphakind: Backupmetadata: name: backup-examplespec: source: "my-kafka-cluster" sink: "my-storage" streams: - topic: "magic.events" topicSelectors: matchers: - name: literal: "spells.proper" - name: glob: "enchantments.*" - name: regex: "^curses\\."In this example, we have changed the streams in our Backup definition:
The “magic.events” topic is still present,
but we added topic “matchers” under the spec.topicSelectors property
that will watch the cluster for new (or existing) topics matching any one of their rules:
-
the topic called “spells.proper” if it is present, or should it appear at some point;
-
any new (or existing) topic matching the glob pattern “enchantments.*”;
-
any new (or existing) topic matching the regular expression “^curses\.”.
Any dynamically added topic via the topicSelectors property
will be backed up using the same configuration options (compression, rollover size, etc)
as the ones explicitly defined in spec.streams.
Pausing and resuming
It is possible to pause a Backup, and resume it later.
When a Backup is paused,
the associated Deployment will be scaled down to 0.
Pausing and resuming a Backup
You can pause a Backup by setting the .spec.enabled field to false.
The following is an example of a Backup which is disabled (paused).
apiVersion: kannika.io/v1alphakind: Backupmetadata: name: paused-backup-examplespec: source: "my-kafka-cluster" sink: "my-bucket" enabled: false streams: - topic: "paused.events"A Backup can be resumed again by setting the spec.enabled field to true again (or by removing the field).
Pausing and resuming a Backup Stream (Topic)
A Backup Stream can be paused by setting the enabled field to false of a Backup Stream.
The following is an example of a Backup Stream which is paused.
apiVersion: kannika.io/v1alphakind: Backupmetadata: name: paused-backup-stream-examplespec: source: "my-kafka-cluster" sink: "my-bucket" enabled: false streams: - topic: "disabled.events" enabled: false # Disables this streamIf a topic satisfies one of the topicSelectors matchers,
then it is possible to pause the Backup for this particular topic by adding it to the spec.streams list
with the enabled flag set to false,
as shown in the following example:
apiVersion: kannika.io/v1alphakind: Backupmetadata: name: paused-backup-stream-examplespec: source: "my-kafka-cluster" sink: "my-bucket" enabled: true streams: - topic: "__consumer_offsets" enabled: false topicSelectors: matchers: - name: glob: "*"Here,
we the topicSelectors rules match all possible topic names,
but we’ve excluded the __consumer_offsets topic by setting enabled.false.