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

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

[role="_abstract"]
Persistent volumes used by a cluster can be resized 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. 

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

IMPORTANT: You cannot decrease the size of persistent volumes because it is not currently supported in Kubernetes.

.Prerequisites

* A Kubernetes cluster with support for volume resizing.
* The Cluster Operator is running.
* A Kafka cluster using persistent volumes created using a storage class that supports volume expansion.

.Procedure

. Edit the `Kafka` resource for your cluster.
+
Change the `size` property to increase the size of the persistent volume allocated to a Kafka cluster, a ZooKeeper cluster, or both.
+
--
* For Kafka clusters, update the `size` property under `spec.kafka.storage`.
* For ZooKeeper clusters, update the `size` property under `spec.zookeeper.storage`.
--
+
.Kafka configuration to increase the volume size to `2000Gi`
[source,yaml,subs=attributes+]
----
apiVersion: {KafkaApiVersion}
kind: Kafka
metadata:
  name: my-cluster
spec:
  kafka:
    # ...
    storage:
      type: persistent-claim
      size: 2000Gi
      class: my-storage-class
    # ...
  zookeeper:
    # ...
----

. Create or update the resource:
+
[source,shell,subs=+quotes]
kubectl apply -f _<kafka_configuration_file>_
+
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.

. Verify that the storage capacity has increased for the relevant pods on the cluster:
+
[source,shell,subs=+quotes]
kubectl get pv
+
.Kafka broker pods with increased storage
[source,shell,subs="+quotes,attributes"]
----
NAME               CAPACITY   CLAIM
pvc-0ca459ce-...   2000Gi     my-project/data-my-cluster-kafka-2
pvc-6e1810be-...   2000Gi     my-project/data-my-cluster-kafka-0
pvc-82dc78c9-...   2000Gi     my-project/data-my-cluster-kafka-1
----
+
The output shows the names of each PVC associated with a broker pod.

[role="_additional-resources"]
.Additional resources

* For more information about resizing persistent volumes in Kubernetes, see {K8sResizingPersistentVolumesUsingKubernetes}.
