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

[id='config-node-pools-{context}']
= Configuring node pools

[role="_abstract"]
Update the `spec` properties of the `KafkaNodePool` custom resource to configure a node pool deployment.
A node pool is a distinct group of Kafka nodes within a Kafka cluster.
The `strimzi.io/cluster` metadata label identifies the name of the Kafka custom resource the pool belongs to.

Each pool has its own unique configuration, including mandatory settings for the number of replicas, roles, and storage allocation.
The `.spec.roles` property defines whether the nodes in the pool act as controllers, brokers, or both.

Optionally, you can also specify values for the following properties:

* `resources` to specify memory and cpu requests and limits
* `template` to specify custom configuration for pods and other Kubernetes resources
* `jvmOptions` to specify custom JVM configuration for heap size, runtime and other options 

The relationship between `Kafka` and `KafkaNodePool` resources is as follows:

* `Kafka` resources represent the configuration for all nodes in a Kafka cluster.
* `KafkaNodePool` resources represent the configuration for nodes only in the node pool.

If a configuration property is not specified in `KafkaNodePool`, it is inherited from the `Kafka` resource.
Configuration specified in the `KafkaNodePool` resource takes precedence if set in both resources.
For example, if both the node pool and Kafka configuration includes `jvmOptions`, the values specified in the node pool configuration are used.
When `-Xmx: 1024m` is set in `KafkaNodePool.spec.jvmOptions` and `-Xms: 512m` is set in `Kafka.spec.kafka.jvmOptions`, the node uses the value from its node pool configuration.

Properties from `Kafka` and `KafkaNodePool` schemas are not combined.  
To clarify, if `KafkaNodePool.spec.template` includes only `podSet.metadata.labels`, and `Kafka.spec.kafka.template` includes `podSet.metadata.annotations` and `pod.metadata.labels`, the template values from the Kafka configuration are ignored since there is a template value in the node pool configuration.

For a deeper understanding of the node pool configuration options, refer to the link:{BookURLConfiguring}[Strimzi Custom Resource API Reference^].

.Example configuration for a node pool in a cluster using KRaft mode 
[source,yaml,subs="+attributes"]
----
# Basic configuration (required)
apiVersion: {KafkaNodePoolApiVersion}
kind: KafkaNodePool
metadata:
  name: kraft-dual-role # <1>
  labels:
    strimzi.io/cluster: my-cluster # <2>
# Node pool specifications
spec:
  # Replicas (required)
  replicas: 3 # <3>
  # Roles (required)
  roles: # <4>
    - controller
    - broker
  # Storage configuration (required)
  storage: # <5>
    type: jbod
    volumes:
      - id: 0
        type: persistent-claim
        size: 100Gi
        deleteClaim: false
  # Resources requests and limits (recommended)
  resources: # <6>
    requests:
      memory: 64Gi
      cpu: "8"
    limits:
      memory: 64Gi
      cpu: "12"
----
<1> Unique name for the node pool.
<2> The Kafka cluster the node pool belongs to. A node pool can only belong to a single cluster.
<3> Number of replicas for the nodes. 
<4> Roles for the nodes in the node pool. In this example, the nodes have dual roles as controllers and brokers.
<5> Storage specification for the nodes. 
<6> Requests for reservation of supported resources, currently `cpu` and `memory`, and limits to specify the maximum resources that can be consumed.

NOTE: The configuration for the `Kafka` resource must be suitable for KRaft mode. Currently, KRaft mode has xref:assembly-kraft-mode-{context}[a number of limitations]. 
