<a id="co-scale-disks"></a>

# Scale Storage for Confluent Platform Using Confluent for Kubernetes

## Scale up disks

The ability to scale up disks is important to successfully use Confluent Platform at scale.
For instance, as your organization’s usage of Kafka grows, you may experience a
large growth in the number of Kafka topics, and expanding disks  help you ensure
you have enough disk space to accommodate the data in those topics.

Confluent for Kubernetes (CFK) enables simple, automated expansion of storage. In a
[supported environment](#co-scale-disks-requirements), you can take a
simple workflow to expand all the disks associated with a cluster. And after
some time, all pods within the cluster are able to leverage expanded disk space
without any interruption. In some cases, this expansion can be completed across
an entire cluster in just a few seconds.

<a id="co-scale-disks-requirements"></a>

### Requirements and considerations

Expanding a disk requires both resizing the PersistentVolumeClaim (PVC) and
expanding the file system exposed to the pod where the given associated
PersistentVolume (PV) is mounted.

The ability to automatically resize a PVC depends on the volume types you use
and how the StorageClass associated with the PVCs is configured. For further
details on PVC expansion support, see [Expanding Persistent Volumes Claims in
Kubernetes](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#expanding-persistent-volumes-claims).

To scale up Confluent Platform storage, the following must be true of your environment:

* The StorageClass associated with your Confluent Platform component cluster must have set
  `allowVolumeExpansion: true`.
* The underlying volume type must support expansion.

  At the time of this writing, GCE Persistent Disk, AWS EBS, Azure Disk, and
  others support expansion, while Host Path and other types of volumes do not.

<a id="co-scale-disks-expand-in-use-persistent-volumes"></a>
* The `ExpandInUsePersistentVolumes` feature must be enabled on your
  Kubernetes cluster.

  Once a PVC is expanded, the ability to automatically expand the file system
  exposed to a pod without restarting the pod requires the
  ExpandInUsePersistentVolumes feature to be enabled on your Kubernetes cluster.
  For Kubernetes clusters with version 1.15 and higher, this feature is enabled
  by default. For further details on expanding in-use PVCs, see [Resizing an
  in-use PersistentVolumeClaim](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#resizing-an-in-use-persistentvolumeclaim).
* Do not increase disk size only for a particular broker. Increasing disk size
  for a particular broker can lead to a DiskUsageDistributionGoal violation due
  to the discrepancy of disk size between the brokers.
* Cloud providers enforce hard limits on volume size. Attempting to expand a PVC
  beyond these limits will push it into an invalid state, preventing further
  resizing. For example, Azure enforces a hard limit of 32 Ti for volume size,
  and you will not be able to expand a PVC beyond this limit on Azure.
* Kubernetes does not support shrinking PVCs once they have been expanded.

<a id="co-expand-storage"></a>

### Expand storage

As stated in the [requirements and considerations](#co-scale-disks-expand-in-use-persistent-volumes) section, when the
`ExpandInUsePersistentVolumes` feature is enabled on your Kubernetes cluster,
storage expansion does not trigger a pod restart.

To expand the disk associated with a Confluent component cluster:

1. Update `dataVolumeCapacity` in your Confluent component custom resource
   (CR).

   For example, to increases the disk for Kafka brokers to 100 Gi:
   ```yaml
   kind: Kafka
   metadata:
     name: kafka
     namespace: confluent
   spec:
     dataVolumeCapacity: 100Gi
   ```
2. Apply the CR change by running the `kubectl apply` command.

## Scale down disks

Scaling down disks is not supported in the current version of CFK.
