Skip to content

    Creating your first backup

    In this guide, you will create a backup of a Kafka topic. The backup will be stored on a Persistent Volume .

    You will configure:

    • The EventHub to define the Kafka cluster.
    • The Credentials to authenticate with the Kafka cluster.
    • The Storage to store data on.
    • The Backup using all of the above.

    Pre-requisites

    To follow this guide, make sure you have the following tools available:

    Step 1: Configure an EventHub

    An EventHub is a Kannika Armory resource that is used to depict an external system that contains event data. In this step, you will create a Kafka EventHub.

    Create the following resource in Kubernetes:

    apiVersion: kannika.io/v1alpha
    kind: EventHub
    metadata:
    name: my-kafka-cluster
    spec:
    kafka:
    properties:
    bootstrap.servers: broker:9092

    In this example:

    • A Kafka EventHub named my-kafka-cluster is created.

    • The EventHub points to a Kafka cluster at broker:9092.


    To authenticate with the Kafka cluster, you’ll need to configure Credentials. In this example, you’ll use SASL/PLAIN Credentials with a username and password.

    Create the following resources in Kubernetes:

    # Define the SASL Credentials
    apiVersion: kannika.io/v1alpha
    kind: Credentials
    metadata:
    name: sasl-creds
    spec:
    sasl:
    mechanism: PLAIN
    usernameFrom:
    secretKeyRef:
    name: sasl-creds # References the Secret below
    key: username
    passwordFrom:
    secretKeyRef:
    name: sasl-creds # References the Secret below
    key: password
    sslConf:
    enabled: true
    ---
    # Define the Secret that contains the username and password
    apiVersion: v1
    kind: Secret
    type: Opaque
    metadata:
    name: sasl-creds
    data:
    username: c2FzbC11c2VybmFtZQ== # sasl-username, base64 encoded
    password: c2FzbC1wYXNzd29yZA=== # sasl-password, base64 encoded

    In this example:

    • The Credentials are used for SASL/PLAIN authentication with the username sasl-username and password sasl-password, which are stored in a Secret named sasl-creds.

    • SSL encryption is enabled. This correlates to the Kafka property security.protocol being set to SASL_SSL.

    Step 2: Configure a Storage

    Next, configure the Storage which will be used to store the backup data. In this example, a Volume Storage is used, which will store the data on a Persistent Volume .

    Create the following Storage resource in Kubernetes:

    apiVersion: kannika.io/v1alpha
    kind: Storage
    metadata:
    name: "my-volume-storage"
    spec:
    volume:
    capacity: 10Gi

    In this example:

    • A Volume Storage named my-volume-storage is created.

    • The volume has a capacity of 10Gi.

    Step 3: Configure the backup

    Finally, create a Backup which will back up data from the EventHub on the Storage.

    Create the following Backup resource in Kubernetes:

    apiVersion: kannika.io/v1alpha
    kind: Backup
    metadata:
    name: "my-backup"
    spec:
    source: "my-kafka-cluster"
    sourceCredentialsFrom:
    credentialsRef:
    name: "sasl-creds"
    sink: "my-volume-storage"
    enabled: true # Optional, defaults to true
    streams:
    - topic: "my-topic"
    enabled: true # Optional, defaults to true

    In this example:

    Step 4: Verify that the backup is running

    Congratulations on making it this far! You have now created your first backup, and it should be running.

    To verify that the backup is running, run the following command:

    Terminal window
    $ kubectl get backups

    You should see output similar to the following:

    Terminal window
    NAME STATUS
    my-backup 🚀 Streaming

    You should also see the associated Pod running:

    Terminal window
    $ kubectl get pods

    You should see output similar to the following:

    Terminal window
    NAME READY STATUS RESTARTS AGE
    my-backup-75465ff49-kcw8p 1/1 Running 0 1s

    The backup is now running, and will continue to run until you delete it, or pause it.