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

[id='proc-managing-storage-node-pools-{context}']
= Managing storage using node pools

[role="_abstract"]
Storage management in Strimzi is usually straightforward, and requires little change when set up, but there might be situations where you need to modify your storage configurations. 
Node pools simplify this process, because you can set up separate node pools that specify your new storage requirements.

In this procedure we create and manage storage for a node pool called `pool-a` containing three nodes.
The steps require a scaling operation to add a new node pool.
Currently, scaling is only possible for broker-only node pools containing nodes that run as dedicated brokers.

We show how to change the storage class (`volumes.class`) that defines the type of persistent storage it uses.
You can use the same steps to change the storage size (`volumes.size`). 
This approach is particularly useful if you want to reduce disk sizes.
When increasing disk sizes, you have the option to xref:proc-resizing-persistent-volumes-{context}[dynamically resize persistent volumes].

NOTE: We strongly recommend using block storage. Strimzi is only tested for use with block storage.

.Prerequisites

* xref:deploying-cluster-operator-str[The Cluster Operator must be deployed.]
* xref:proc-configuring-deploying-cruise-control-str[Cruise Control is deployed with Kafka.]
* For storage that uses persistent volume claims for dynamic volume allocation, storage classes are defined and available in the Kubernetes cluster that correspond to the storage solutions you need. 

.Procedure

. Create the node pool with its own storage settings.
+
For example, node pool `pool-a` uses JBOD storage with persistent volumes:
+
[source,yaml,subs="+attributes"]
----
apiVersion: {KafkaNodePoolApiVersion}
kind: KafkaNodePool
metadata:
  name: pool-a
  labels:
    strimzi.io/cluster: my-cluster
spec:
  roles:
    - broker
  replicas: 3
  storage:
    type: jbod
    volumes:
      - id: 0
        type: persistent-claim
        size: 500Gi
        class: gp2-ebs
  # ...
----
+
Nodes in `pool-a` are configured to use Amazon EBS (Elastic Block Store) GP2 volumes.

. Apply the node pool configuration for `pool-a`.
. Check the status of the deployment and wait for the pods in `pool-a` to be created and ready (`1/1`).
+
[source,shell]
----
kubectl get pods -n <my_cluster_operator_namespace>
----
+
.Output shows three Kafka nodes in the node pool
[source,shell]
----
NAME                 READY  STATUS   RESTARTS
my-cluster-pool-a-0  1/1    Running  0
my-cluster-pool-a-1  1/1    Running  0
my-cluster-pool-a-2  1/1    Running  0
----

. To migrate to a new storage class, create a new node pool with the required storage configuration:
+
[source,yaml,subs="+attributes"]
----
apiVersion: {KafkaNodePoolApiVersion}
kind: KafkaNodePool
metadata:
  name: pool-b
  labels:
    strimzi.io/cluster: my-cluster
spec:
  roles:
    - broker
  replicas: 3
  storage:
    type: jbod
    volumes:
      - id: 0
        type: persistent-claim
        size: 1Ti
        class: gp3-ebs
  # ...
----
+
Nodes in `pool-b` are configured to use Amazon EBS (Elastic Block Store) GP3 volumes.

. Apply the node pool configuration for `pool-b`.
. Check the status of the deployment and wait for the pods in `pool-b` to be created and ready.
. Reassign the partitions from `pool-a` to `pool-b`.
+
When migrating to a new storage configuration, use the Cruise Control `remove-brokers` mode to move partition replicas off the brokers that are going to be removed.
+
.Using Cruise Control to reassign partition replicas
[source,shell,subs="+attributes"]
----
apiVersion: {KafkaRebalanceApiVersion}
kind: KafkaRebalance
metadata:
  # ...
spec:
  mode: remove-brokers
  brokers: [0, 1, 2]
----
+
We are reassigning partitions from `pool-a`. 
The reassignment can take some time depending on the number of topics and partitions in the cluster.

. After the reassignment process is complete, delete the old node pool:
+
[source, shell]
----
kubectl delete kafkanodepool pool-a
----
