// Module included in the following assemblies:
//
// assembly-config.adoc

[id='proc-migrating-clusters-node-pools-{context}']
= (Preview) Migrating existing Kafka clusters to use Kafka node pools

[role="_abstract"]
This procedure describes how to migrate existing Kafka clusters to use Kafka node pools.
After you have updated the Kafka cluster, you can use the node pools to manage the configuration of nodes within each pool.

NOTE: While the `KafkaNodePools` feature gate that enables node pools is in alpha phase, replica and storage configuration in the `KafkaNodePool` resource must also be present in the `Kafka` resource. The configuration is ignored when node pools are being used. 

.Prerequisites

* xref:deploying-cluster-operator-str[The Cluster Operator must be deployed.]

.Procedure

. Create a new `KafkaNodePool` resource.
+
--
.. Name the resource `kafka`.
.. Point a `strimzi.io/cluster` label to your existing `Kafka` resource.
.. Set the replica count and storage configuration to match your current Kafka cluster.
.. Set the roles to `broker`.
--
+
.Example configuration for a node pool used in migrating a Kafka cluster
[source,yaml,subs="+attributes"]
----
apiVersion: {KafkaNodePoolApiVersion}
kind: KafkaNodePool
metadata:
  name: kafka
  labels:
    strimzi.io/cluster: my-cluster
spec:
  replicas: 3
  roles:
    - broker
  storage:
    type: jbod
    volumes:
      - id: 0
        type: persistent-claim
        size: 100Gi
        deleteClaim: false
----

. Apply the `KafkaNodePool` resource:
+
[source,shell,subs=+quotes]
----
kubectl apply -f <node_pool_configuration_file>
----
+
By applying this resource, you switch Kafka to using node pools.
+
There is no change or rolling update and resources are identical to how they were before.

. Update the `STRIMZI_FEATURE_GATES` environment variable in the Cluster Operator configuration to include `+KafkaNodePools`.
+
[source,yaml]
----
env:
  - name: STRIMZI_FEATURE_GATES
    value: +KafkaNodePools
----

. Enable the `KafkaNodePools` feature gate in the `Kafka` resource using the `strimzi.io/node-pools: enabled` annotation.
+
.Example configuration for a node pool in a cluster using ZooKeeper
[source,yaml,subs="+attributes"]
----
apiVersion: {KafkaApiVersion}
kind: Kafka
metadata:
  name: my-cluster
  annotations:
    strimzi.io/node-pools: enabled
spec:
  kafka:
    version: {DefaultKafkaVersion}
    replicas: 3
  # ...
  storage:
      type: jbod
      volumes:
      - id: 0
        type: persistent-claim
        size: 100Gi
        deleteClaim: false
----

. Apply the `Kafka` resource:
+
[source,shell,subs=+quotes]
----
kubectl apply -f <kafka_configuration_file>
----