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

[id='proc-scaling-up-node-pools-{context}']
= Adding nodes to a node pool

[role="_abstract"]
This procedure describes how to scale up a node pool to add new nodes.
Currently, scale up is only possible for broker-only node pools containing nodes that run as dedicated brokers.

In this procedure, we start with three nodes for node pool `pool-a`:

.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
----

Node IDs are appended to the name of the node on creation.
We add node `my-cluster-pool-a-3`, which has a node ID of `3`.

NOTE: During this process, the ID of the node that holds the partition replicas changes. Consider any dependencies that reference the node ID.

.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.]
* (Optional) xref:proc-automating-rebalances-{context}[Auto-rebalancing is enabled]. +
If auto-rebalancing is enabled, partition reassignment happens automatically during the node scaling process, so you don't need to manually initiate the reassignment through Cruise Control.
* (Optional) For scale up operations, xref:proc-managing-node-pools-ids-{context}[you can specify the node IDs to use in the operation]. +
If you have assigned a range of node IDs for the operation, the ID of the node being added is determined by the sequence of nodes given. 
If you have assigned a single node ID, a node is added with the specified ID.
Otherwise, the lowest available node ID across the cluster is used.  

.Procedure

. Create a new node in the node pool.
+
For example, node pool `pool-a` has three replicas. We add a node by increasing the number of replicas:
+
[source,shell]
----
kubectl scale kafkanodepool pool-a --replicas=4
----

. Check the status of the deployment and wait for the pods in the node pool to be created and ready (`1/1`).
+
[source,shell]
----
kubectl get pods -n <my_cluster_operator_namespace>
----
+
.Output shows four 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
my-cluster-pool-a-3  1/1    Running  0
----

. Reassign the partitions after increasing the number of nodes in the node pool.
+
* If auto-rebalancing is enabled, partitions are reassigned to new nodes automatically, so you can skip this step.  
* If auto-rebalancing is not enabled, use the Cruise Control `add-brokers` mode to move partition replicas from existing brokers to the newly added brokers.
+
.Using Cruise Control to reassign partition replicas
[source,shell,subs="+attributes"]
----
apiVersion: {KafkaRebalanceApiVersion}
kind: KafkaRebalance
metadata:
  # ...
spec:
  mode: add-brokers
  brokers: [3]
----
+
We are reassigning partitions to node `my-cluster-pool-a-3`. 
The reassignment can take some time depending on the number of topics and partitions in the cluster.