Skip to content

Commit

Permalink
docs(storage): updates the storage content for KRaft and node pools (#…
Browse files Browse the repository at this point in the history
…10731)

Signed-off-by: prmellor <[email protected]>
  • Loading branch information
PaulRMellor authored Oct 25, 2024
1 parent 8a17029 commit 6690fbc
Show file tree
Hide file tree
Showing 16 changed files with 471 additions and 652 deletions.
8 changes: 3 additions & 5 deletions documentation/assemblies/configuring/assembly-config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,11 @@ include::../../modules/configuring/proc-moving-node-pools.adoc[leveloffset=+2]
include::../../modules/configuring/con-config-node-pool-roles.adoc[leveloffset=+2]
include::../../modules/configuring/proc-splitting-node-pool-roles.adoc[leveloffset=+2]
include::../../modules/configuring/proc-joining-node-pool-roles.adoc[leveloffset=+2]
include::../../modules/configuring/proc-managing-storage-node-pools.adoc[leveloffset=+2]
include::../../modules/configuring/proc-managing-storage-affinity-node-pools.adoc[leveloffset=+2]
include::../../modules/configuring/proc-migrating-clusters-node-pools.adoc[leveloffset=+2]

//configuring storage
include::assembly-storage.adoc[leveloffset=+1]

//`Kafka` config for operators
include::../../modules/configuring/ref-kafka-entity-operator.adoc[leveloffset=+1]
//topic operator config
Expand Down Expand Up @@ -171,9 +172,6 @@ include::../../modules/configuring/con-config-mirrormaker.adoc[leveloffset=+1]
//`KafkaBridge` resource config
include::../../modules/configuring/con-config-kafka-bridge.adoc[leveloffset=+1]

//configuring Kafka and ZooKeeper storage
include::../../assemblies/configuring/assembly-storage.adoc[leveloffset=+1]

//configuring CPU and memory resources and limits
include::../../modules/configuring/con-config-resources.adoc[leveloffset=+1]

Expand Down
65 changes: 27 additions & 38 deletions documentation/assemblies/configuring/assembly-storage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,43 @@
// assembly-config.adoc

[id='assembly-storage-{context}']
= Configuring Kafka and ZooKeeper storage
= Configuring Kafka storage

[role="_abstract"]
Strimzi provides flexibility in configuring the data storage options of Kafka and ZooKeeper.
Strimzi supports different Kafka storage options.
You can choose between the following basic types:

The supported storage types are:
Ephemeral storage:: Ephemeral storage is temporary and only persists while a pod is running.
When a pod is deleted, the data is lost, though data can be recovered in a highly available environment.
Due to its transient nature, ephemeral storage is only recommended for development and testing environments.

* Ephemeral (Recommended for development only)
* Persistent
* JBOD (Kafka only; not available for ZooKeeper)
* Tiered storage (Early access)
Persistent storage:: Persistent storage retains data across pod restarts and system disruptions, making it ideal for production environments.

To configure storage, you specify `storage` properties in the custom resource of the component.
The storage type is set using the `storage.type` property.
When using node pools, you can specify storage configuration unique to each node pool used in a Kafka cluster.
The same storage properties available to the `Kafka` resource are also available to the `KafkaNodePool` pool resource.
JBOD (Just a Bunch of Disks) storage allows you to configure your Kafka cluster to use multiple disks or volumes as ephemeral or persistent storage.

Tiered storage provides more flexibility for data management by leveraging the parallel use of storage types with different characteristics.
For example, tiered storage might include the following:
.JBOD storage (multiple volumes)
When specifying JBOD storage, you must still decide between using ephemeral or persistent volumes for each disk.
Even if you start with only one volume, using JBOD allows for future scaling by adding more volumes as needed, and that is why it is always recommended.

* Higher performance and higher cost block storage
* Lower performance and lower cost object storage
NOTE: Persistent, ephemeral, and JBOD storage types cannot be changed after a Kafka cluster is deployed.
However, you can add or remove volumes of different types from the JBOD storage.
You can also create and migrate to node pools with new storage specifications.

Tiered storage is an early access feature in Kafka.
To configure tiered storage, you specify `tieredStorage` properties.
Tiered storage is configured only at the cluster level using the `Kafka` custom resource.
.Tiered storage (advanced)

The storage-related schema references provide more information on the storage configuration properties:
Tiered storage, currently available as an early access feature, provides additional flexibility for managing Kafka data by combining different storage types with varying performance and cost characteristics.
It allows Kafka to offload older data to cheaper, long-term storage (such as object storage) while keeping recent, frequently accessed data on faster, more expensive storage (such as block storage).

* link:{BookURLConfiguring}#type-EphemeralStorage-reference[`EphemeralStorage` schema reference^]
* link:{BookURLConfiguring}#type-PersistentClaimStorage-reference[`PersistentClaimStorage` schema reference^]
* link:{BookURLConfiguring}#type-JbodStorage-reference[`JbodStorage` schema reference^]
* link:{BookURLConfiguring}#type-TieredStorageCustom-reference[`TieredStorageCustom` schema reference^]

WARNING: The storage type cannot be changed after a Kafka cluster is deployed.
Tiered storage is an add-on capability.
After configuring storage (ephemeral, persistent, or JBOD) for Kafka nodes, you can configure tiered storage at the cluster level and enable it for specific topics using the `remote.storage.enable` topic-level configuration.

include::../../modules/configuring/con-considerations-for-data-storage.adoc[leveloffset=+1]

include::../../modules/configuring/ref-storage-ephemeral.adoc[leveloffset=+1]

include::../../modules/configuring/ref-storage-persistent.adoc[leveloffset=+1]

include::../../modules/configuring/proc-resizing-persistent-volumes.adoc[leveloffset=+1]

include::../../modules/configuring/ref-storage-jbod.adoc[leveloffset=+1]

include::../../modules/configuring/proc-adding-volumes-to-jbod-storage.adoc[leveloffset=+1]

include::../../modules/configuring/proc-removing-volumes-from-jbod-storage.adoc[leveloffset=+1]

include::../../modules/configuring/ref-storage-tiered.adoc[leveloffset=+1]
//KRaft storage
include::../../modules/configuring/con-config-storage-kraft.adoc[leveloffset=+1]
include::../../modules/configuring/proc-managing-storage-node-pools.adoc[leveloffset=+2]
include::../../modules/configuring/proc-managing-storage-affinity-node-pools.adoc[leveloffset=+2]
//ZooKeeper storage
include::../../modules/configuring/con-config-storage-zookeeper.adoc[leveloffset=+1]
//tiered storage
include::../../modules/configuring/ref-storage-tiered.adoc[leveloffset=+1]
3 changes: 1 addition & 2 deletions documentation/assemblies/deploying/assembly-kraft-mode.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Kafka uses this metadata to coordinate changes and manage the cluster effectivel

Broker nodes act as observers, storing the metadata log passively to stay up-to-date with the cluster's state.
Each node fetches updates to the log independently.
If you are using JBOD storage, you can xref:con-storing-metadata-log-{context}[change the volume that stores the metadata log].

NOTE: The KRaft metadata version used in the Kafka cluster must be supported by the Kafka version in use.
Both versions are managed through the `Kafka` resource configuration.
Expand All @@ -55,7 +56,5 @@ Currently, the KRaft mode in Strimzi has the following major limitations:

* Scaling of KRaft controller nodes up or down is not supported.

NOTE: If you are using JBOD storage, you can xref:ref-jbod-storage-str[change the volume that stores the metadata log].

//migrating to KRaft
include::../../modules/deploying/proc-deploy-migrate-kraft.adoc[leveloffset=+1]
250 changes: 250 additions & 0 deletions documentation/modules/configuring/con-config-storage-kraft.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
// Module included in the following assemblies:
//
// assembly-storage.adoc

[id='con-config-storage-kraft-{context}']
= Configuring Kafka storage in KRaft mode

[role="_abstract"]
Use the `storage` properties of the `KafkaNodePool` custom resource to configure storage for a deployment of Kafka in KRaft mode.

== Configuring ephemeral storage

To use ephemeral storage, specify `ephemeral` as the storage type.

.Example configuration for ephemeral storage
[source,yaml,subs="+attributes"]
----
apiVersion: {KafkaNodePoolApiVersion}
kind: KafkaNodePool
metadata:
name: my-node-pool
labels:
strimzi.io/cluster: my-cluster
spec:
replicas: 3
roles:
- broker
storage:
type: ephemeral
# ...
----

Ephemeral storage uses {K8sEmptyDir} volumes, which are created when a pod is assigned to a node.
You can limit the size of the `emptyDir` volume with the `sizeLimit` property.

The ephemeral volume used by Kafka brokers for log directories is mounted at `/var/lib/kafka/data/kafka-log<pod_id>`.

IMPORTANT: Ephemeral storage is not suitable for Kafka topics with a replication factor of 1.

For more information on ephemeral storage configuration options, see the link:{BookURLConfiguring}#type-EphemeralStorage-reference[`EphemeralStorage` schema reference^].

== Configuring persistent storage

To use persistent storage, specify one of the following as the storage type:

* `persistent-claim` for a single persistent volume
* `jbod` for multiple persistent volumes in a Kafka cluster (Recommended for Kafka in a production environment)

.Example configuration for persistent storage
[source,yaml,subs="+attributes"]
----
apiVersion: {KafkaNodePoolApiVersion}
kind: KafkaNodePool
metadata:
name: my-node-pool
labels:
strimzi.io/cluster: my-cluster
spec:
replicas: 3
roles:
- broker
storage:
type: persistent-claim
size: 500Gi
deleteClaim: true
# ...
----

Strimzi uses {K8sPersistentVolumeClaims} (PVCs) to request storage on persistent volumes (PVs).
The PVC binds to a PV that meets the requested storage criteria, without needing to know the underlying storage infrastructure.

PVCs created for Kafka pods follow the naming convention `data-<kafka_cluster_name>-<pool_name>-<pod_id>`, and the persistent volumes for Kafka logs are mounted at `/var/lib/kafka/data/kafka-log<pod_id>`.

You can also specify custom storage classes ({K8SStorageClass}) and volume selectors in the storage configuration.

.Example class and selector configuration
[source,yaml,subs="attributes+"]
----
# ...
storage:
type: persistent-claim
size: 500Gi
class: my-storage-class
selector:
hdd-type: ssd
deleteClaim: true
# ...
----

Storage classes define storage profiles and dynamically provision persistent volumes (PVs) based on those profiles.
This is useful, for example, when storage classes are restricted to different availability zones or data centers.
If a storage class is not specified, the default storage class in the Kubernetes cluster is used.
Selectors specify persistent volumes that offer specific features, such as solid-state drive (SSD) volumes.

For more information on persistent storage configuration options, see the link:{BookURLConfiguring}#type-PersistentClaimStorage-reference[`PersistentClaimStorage` schema reference^].

[id='proc-resizing-persistent-volumes-{context}']
== Resizing persistent volumes

Persistent volumes can be resized by changing the `size` storage property without any risk of data loss, as long as the storage infrastructure supports it.
Following a configuration update to change the size of the storage, Strimzi instructs the storage infrastructure to make the change.

Storage expansion is supported in Strimzi clusters that use persistent-claim volumes.
Decreasing the size of persistent volumes is not supported in Kubernetes.
For more information about resizing persistent volumes in Kubernetes, see {K8sResizingPersistentVolumesUsingKubernetes}.

After increasing the value of the `size` property, Kubernetes increases the capacity of the selected persistent volumes in response to a request from the Cluster Operator.
When the resizing is complete, the Cluster Operator restarts all pods that use the resized persistent volumes.
This happens automatically.

In this example, the volumes are increased to 2000Gi.

.Kafka configuration to increase volume size to `2000Gi`
[source,yaml,subs=attributes+]
----
apiVersion: {KafkaNodePoolApiVersion}
kind: KafkaNodePool
metadata:
name: my-node-pool
labels:
strimzi.io/cluster: my-cluster
spec:
replicas: 3
roles:
- broker
storage:
type: jbod
volumes:
- id: 0
type: persistent-claim
size: 2000Gi
deleteClaim: false
- id: 1
type: persistent-claim
size: 2000Gi
deleteClaim: false
- id: 2
type: persistent-claim
size: 2000Gi
deleteClaim: false
# ...
----

Returning information on the PVs verifies the changes:

[source,shell,subs=+quotes]
----
kubectl get pv
----

.Storage capacity of PVs
[source,shell,subs="+quotes,attributes"]
----
NAME CAPACITY CLAIM
pvc-0ca459ce-... 2000Gi my-project/data-my-cluster-my-node-pool-2
pvc-6e1810be-... 2000Gi my-project/data-my-cluster-my-node-pool-0
pvc-82dc78c9-... 2000Gi my-project/data-my-cluster-my-node-pool-1
----

The output shows the names of each PVC associated with a broker pod.

NOTE: Storage _reduction_ is only possible when using multiple disks per broker.
You can remove a disk after moving all partitions on the disk to other volumes within the same broker (intra-broker) or to other brokers within the same cluster (intra-cluster).


== Configuring JBOD storage

To use JBOD storage, specify `jbod` as the storage type and add configuration for the JBOD volumes.
JBOD volumes can be persistent or ephemeral, with the configuration options and constraints applicable to each type.

.Example configuration for JBOD storage
[source,yaml,subs="+attributes"]
----
apiVersion: {KafkaNodePoolApiVersion}
kind: KafkaNodePool
metadata:
name: my-node-pool
labels:
strimzi.io/cluster: my-cluster
spec:
replicas: 3
roles:
- broker
storage:
type: jbod
volumes:
- id: 0
type: persistent-claim
size: 100Gi
deleteClaim: false
- id: 1
type: persistent-claim
size: 100Gi
deleteClaim: false
- id: 2
type: persistent-claim
size: 100Gi
deleteClaim: false
# ...
----

PVCs are created for the JBOD volumes using the naming convention `data-<volume_id>-<kafka_cluster_name>-<pool_name>-<pod_id>`, and the JBOD volumes used for log directories are mounted at `/var/lib/kafka/data-<volume_id>/kafka-log<pod_id>`.

[id='proc-adding-removing-volumes-{context}']
== Adding or removing volumes from JBOD storage

Volume IDs cannot be changed once JBOD volumes are created, though you can add or remove volumes.
When adding a new volume to the to the `volumes` array under an `id` which was already used in the past and removed, make sure that the previously used `PersistentVolumeClaims` have been deleted.

Use Cruise Control to reassign partitions when adding or removing volumes.
For information on intra-broker disk balancing, see xref:con-rebalance-{context}[].

[id='con-storing-metadata-log-{context}']
== Configuring KRaft metadata log storage

In KRaft mode, each node (including brokers and controllers) stores a copy of the Kafka cluster's metadata log on one of its data volumes.
By default, the log is stored on the volume with the lowest ID, but you can specify a different volume using the `kraftMetadata` property.

For controller-only nodes, storage is exclusively for the metadata log.
Since the log is always stored on a single volume, using JBOD storage with multiple volumes does not improve performance or increase available disk space.

In contrast, broker nodes or nodes that combine broker and controller roles can share the same volume for both the metadata log and partition replica data, optimizing disk utilization.
They can also use JBOD storage, where one volume is shared for the metadata log and partition replica data, while additional volumes are used solely for partition replica data.

Changing the volume that stores the metadata log triggers a rolling update of the cluster nodes, involving the deletion of the old log and the creation of a new one in the specified location.
If `kraftMetadata` isn't specified, adding a new volume with a lower ID also prompts an update and relocation of the metadata log.

.Example JBOD storage configuration using volume with ID 1 to store the KRaft metadata
[source,yaml,subs="attributes+"]
----
apiVersion: {KafkaApiVersion}
kind: KafkaNodePool
metadata:
name: pool-a
# ...
spec:
storage:
type: jbod
volumes:
- id: 0
type: persistent-claim
size: 100Gi
deleteClaim: false
- id: 1
type: persistent-claim
size: 100Gi
kraftMetadata: shared
deleteClaim: false
# ...
----
Loading

0 comments on commit 6690fbc

Please sign in to comment.