MQTT Broker Storage Volumes in Kubernetes
Configure initial storage sizes for new deployments and resize existing broker volumes in Kubernetes environments.
The disk space required for MQTT brokers depends on your use case, particularly regarding the use of QoS levels greater than 0, retained messages, and message sizes. Since storage requirements cannot be perfectly predicted, you may need to resize existing volumes or configure appropriate initial sizes.
This document covers both configuring initial storage volume sizes and resizing existing volumes to increase available disk space with minimal service interruption.
The resizing procedure involves removing the StatefulSet, which leaves the broker cluster vulnerable to failures caused by cluster events or human error. Execute this procedure with great care and only in a stable cluster environment.
Configuring Initial Storage Volume Sizes
When deploying Connectware, you can configure the storage volume sizes for the MQTT broker through Helm values. The broker uses two volumes:
data
Stores retained messages, offline queues, and cluster metadata
global.broker.storage.data.size
1Gi
log
Stores log files
global.broker.storage.log.size
100Mi
Prerequisites
Helm version 3 is installed on your system
The Kubernetes command-line tool kubectl is configured and has access to the target installation
You know the name and namespace of your Connectware installation. See Obtaining the name, namespace, and version of your Connectware installation
The
values.yamlfile is available
Procedure
Configure the storage volume sizes by adding the appropriate Helm values to your
values.yamlfile:
Example
global:
broker:
storage:
data:
size: 5Gi
log:
size: 500MiApply the configuration changes using the
helm upgradecommand:
Resizing Existing Storage Volumes
Use this procedure to increase the available disk space for existing broker volumes (PersistentVolumeClaims). This process requires pod restarts, which means clients will need to reconnect.
Prerequisites
kubectlaccess to the installation with the current context namespace set to the target namespace (kubectl config set-context --current --namespace <target-namespace>).A
StorageClassthat supports volume expansion. Verify this by runningkubectl get scand checking thatALLOWVOLUMEEXPANSIONshowstruefor the StorageClass used by the volumes.
Preparing the Broker Cluster
Ensure you have a healthy broker cluster of at least two pods. Run
kubectl get sts brokerand verify it showsREADY 2/2or higher with matching numbers on both sides of the slash.If you only have a single broker, scale the StatefulSet to two replicas:
Export the StatefulSet definition to a local file:
Resizing Volumes
Repeat this procedure for each broker pod in your cluster.
Delete the broker StatefulSet while leaving the pods as orphans:
Set the
$brokervariable to the pod name of the broker you want to resize (e.g.,broker-0):
Delete the broker pod:
Increase the PersistentVolumeClaims size. Replace
<size>with the desired Kubernetes quantity for the volume (e.g.,5Gi):
This example resizes the data volume:
If you also need to resize the log volume, repeat this step for the log PersistentVolumeClaims:
Wait until the PersistentVolumeClaims shows the correct capacity:
Recreate the StatefulSet:
Wait for the StatefulSet to recreate the missing pod. Monitor the status by running
kubectl get sts brokeruntil it showsREADY 2/2or higher with matching numbers on both sides of the slash.Verify that all cluster members show consistent cluster information:
The output should look similar to this:
Repeat this procedure for each additional broker pod until all volumes are resized.
Persisting Volume Changes for Future Deployments
After resizing volumes, update your Helm values to reflect the new sizes for future deployments and upgrades. This prevents future Helm upgrades from reverting the volume size.
Update the following fields in your
values.yamlfile based on the volumes you resized:
brokerdata-broker-*
global.broker.storage.data.size
brokerlog-broker-*
global.broker.storage.log.size
Apply the configuration changes via the
helm upgradecommand:
For more information, see Applying Helm Configuration Changes.
Last updated
Was this helpful?

