Migration from Zookeper to Apache Kafka Raft (KRaft) for Kafka online
KRaft replaces Zookeeper. Kafka pods become brokers, and Zookeeper pods become controllers. Kafka runs on dual-mode during the migration.
Prerequisites
To bootstrap from a live cluster, complete the following steps:
Make sure that all the operator and datastore pods are running before you begin the migration.
kubectl get all -n instana-kafka
Migration Steps
-
You must enable node-pool to support both broker and controller.
kubectl annotate kafka instana -n instana-kafka strimzi.io/node-pools="enabled" --overwrite
-
Disable KRaft.
kubectl annotate kafka instana -n instana-kafka strimzi.io/kraft="disabled" --overwrite
-
Create a YAML file for the broker. For example,
kafka-broker.yaml
with the broker configuration.apiVersion: kafka.strimzi.io/v1beta2 kind: KafkaNodePool metadata: name: kafka labels: strimzi.io/cluster: instana spec: replicas: 3 roles: - broker storage: type: jbod volumes: - id: 0 type: persistent-claim size: 50Gi deleteClaim: true template: pod: tmpDirSizeLimit: 500Mi
-
Deploy Broker.
kubectl apply -f kafka-broker.yaml -n instana-kafka
Broker pods appear.
-
Create a YAML file for the controller. For example,
kafka-controller.yaml
with the controller configuration.apiVersion: kafka.strimzi.io/v1beta2 kind: KafkaNodePool metadata: name: controller labels: strimzi.io/cluster: instana spec: replicas: 3 roles: - controller storage: type: persistent-claim size: 50Gi deleteClaim: true template: pod: tmpDirSizeLimit: 500Mi
-
Deploy Controller.
kubectl apply -f kafka-controller.yaml -n instana-kafka
You can use this command to verify the state of node pools.
kubectl get kafka kafka -n instana-kafka -o jsonpath='{.status.kafkaNodePools}'
-
Enable migration.
kubectl annotate kafka instana -n instana-kafka strimzi.io/kraft="migration" --overwrite
Controller pods appear, and broker pods restart to connect with the controller.
-
Verify the migration status.
kubectl get kafka instana -n instana-kafka -o jsonpath='{.status.kafkaMetadataState}'
-
Replica and storage fields in the kafka.yaml are ignored now. You can remove these fields from the file.
apiVersion: kafka.strimzi.io/v1beta2 kind: Kafka metadata: ... spec: kafka: ... # replicas: 3 ... # storage: # type: jbod # volumes: # - id: 0 # type: persistent-claim # size: 50Gi # deleteClaim: true # zookeeper: # replicas: 3 # storage: # type: persistent-claim # size: 5Gi # deleteClaim: true ...
-
Set the KRaft status to enable when the state is 'KRaftPostMigration'.
kubectl annotate kafka instana -n instana-kafka strimzi.io/kraft="enabled" --overwrite
Broker and controller pods are restarted. Kafka and Zookeeper pods are terminated.
- Verify the migration status again.
kubectl get kafka instana -n instana-kafka -o jsonpath='{.status.kafkaMetadataState}'
The state must show KRaft now.
- Verify the deployment.
kubectl get all -n instana-kafka
The output might be as the following example.
NAME READY STATUS RESTARTS AGE
pod/instana-entity-operator-8564975588-mrz2f 3/3 Running 0 15m
pod/instana-kafka-0 1/1 Running 0 16m
pod/instana-kafka-1 1/1 Running 0 16m
pod/instana-kafka-2 1/1 Running 0 16m
pod/instana-controller-0 1/1 Running 0 17m
pod/instana-controller-1 1/1 Running 0 17m
pod/instana-controller-2 1/1 Running 0 17m
pod/strimzi-cluster-operator-cf49c75d8-qm8jq 1/1 Running 0 34m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/instana-kafka-bootstrap ClusterIP 192.168.1.239 <none> 9091/TCP,9092/TCP 16m
service/instana-kafka-brokers ClusterIP None <none> 9090/TCP,9091/TCP,9092/TCP 16m
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/instana-entity-operator 1/1 1 1 15m
deployment.apps/strimzi-cluster-operator 1/1 1 1 34m
NAME DESIRED CURRENT READY AGE
replicaset.apps/instana-entity-operator-8564975588 1 1 1 15m
replicaset.apps/strimzi-cluster-operator-cf49c75d8 1 1 1 34m