Migrating to Kraft

Objective

Migrate from Zookeeper to Kraft.

Create Kraft Controller KafkaNodePool

Add a new KafkaNodePool to the axual-kafka configuration. The new controller nodepool will use the same Zookeeper configuration, and will be as follows:

values.yaml
axual-kafka:
  kafkaNodePools:
    controller:
      nextNodeIds: "[`<Choose a Range for Controller IDs>`]" ## example: `nextNodeIds: "[100-199]"`
      replicas: <axual-kafka.zookeeper.replicas>
      resources:
        limits:
          memory: <axual-kafka.zookeeper.resources.limits.memory>
        requests:
          cpu: <axual-kafka.zookeeper.resources.requests.cpu>
          memory: <axual-kafka.zookeeper.resources.requests.memory>
      templ: <axual-kafka.zookeeper.templ>
      roles:
        - controller
      storage:
        type: <axual-streaming.kafka.kafka.storageType>
        volumes:
          - deleteClaim: false
            id: 0
            <axual-streaming.zookeeper.storage>

After adding this nodepool, the cluster will show a Degraded status, as the Kafka resource annotation is still strimzi.io/kraft: disabled. This will be resolved in the next step. The error in the Strimzi operator logs will be: The Kafka cluster <cluster_name> is invalid: [KafkaNodePool controller contains invalid roles configuration. In a ZooKeeper-based Kafka cluster, the KafkaNodePool role has to be always set only to the 'broker' role.] New controller pods will be created with the same number of replicas as Zookeeper.

If you are using affinity rules for your controller scheduling, use the following labels for controller:

  • strimzi.io/controller-role: "true"

  • strimzi.io/cluster: <axual-kafka.fullnameOverride>

Migrate from Zookeeper to Kraft

First Step: Both Zookeeper and Kraft Enabled

Update axual-kafka.kafka.kraft from disabled to migration.

  1. Push the changes. The only change is that the strimzi.io/kraft: annotation will be updated to migration.

  2. Watch Kafka resources. At first, the Kafka cluster resource METADATA STATE will be KRaftMigration.

  3. Brokers will restart; wait until this is complete.

  4. The Kafka cluster resource METADATA STATE will change to KRaftDualWriting.

  5. Another broker restart will occur; wait until this is complete.

  6. The Kafka cluster resource METADATA STATE will change to KRaftPostMigration.

First Step Verification

  1. Brokers are healthy.

  2. You can produce/consume messages.

  3. If the verification failed, initiate a rollback.

Second Step: Full Migration to Kraft

  1. Update axual-kafka.kafka.kraft from migration to enabled.

Once you enable Kraft, there is no way to roll back. Therefore, the "Rollback Migration" steps below are not applicable in this case.

  1. Kraft controllers will restart; wait until this is complete.

  2. Brokers will restart; wait until this is complete.

  3. The Kafka cluster resource METADATA STATE will change to PreKRaft.

  4. The Kafka cluster resource METADATA STATE will change to KRaft.

  5. Now, you can disable Zookeeper by setting axual-kafka.zookeeper.enabled to false.

Disabling Zookeeper will be done with no broker restart.

Migration Verification

  1. Brokers are healthy.

  2. You can produce/consume messages.

Rollback Migration

If you decided to roll back the migration and axual-kafka.kafka.kraft is still not changed from migration to enabled, do the following steps:

  1. Ensure the Kafka resource METADATA STATE is KRaftPostMigration.

  2. Change axual-kafka.kafka.kraft from migration to rollback.

  3. Kafka brokers will restart.

  4. The Kafka resource METADATA STATE will change to KRaftDualWriting.

  5. Change axual-kafka.kafka.kraft from rollback to disabled.

  6. Remove the controller kafkaNodePool from axual-kafka.kafkaNodePools.

  7. Brokers will restart. When this is complete, the Kafka resource METADATA STATE will revert to ZooKeeper.