Resizing Broker Volumes in Kubernetes

The disk space needed for our brokers depends on customers use-cases, especially in regards to use of QoS > 0 and retained messages, as well as message size. We can therefore not perfectly predict the necessary disk space, allowing for a situation in which existing volumes need to be resized.

This procedure can be used to increase the available disk space for broker volumes with as little service interruption as possible. Currently this means pod restarts, which result in the necessity for clients to reconnect.

This guide can be used for control-plane-broker by replacing any mention of broker with control-plane-broker.

Important: This procedure depends on removing the StatefulSet. This leaves the broker cluster open to failures caused by cluster events or human error. Therefore this should be executed with great care and only in a stable cluster!

Prerequisites

  1. kubectl access to the necessary installation and the current context namespace set to the target namespace (kubectl config set-context --current --namespace <target-namespace>)
  2. A StorageClass that supports volume resizing (kubectl get sc and check that ALLOWVOLUMEEXPANSION show true for the StorageClass used for the volumes

Instructions

Prepare the broker cluster

  1. Make sure that you have a healthy broker cluster of at least two pods (kubectl get sts broker shows READY 2/2 or higher, but same number on both sides of the slash)
  2. If you only have a single broker, scale the StatefulSet to two:
<code>kubectl scale sts broker --replicas 2</code>
Code-Sprache: YAML (yaml)
  1. Export the StatefulSet definition to a local file:
<code>kubectl get sts broker -o yaml > broker.yaml</code>
Code-Sprache: YAML (yaml)

Resizing Volumes

Repeat this part for each broker cluster pod you have!

  1. Delete the broker StatufulSet while leaving the pods as orphans:
<code>kubectl delete sts broker --cascade=orphan</code>
Code-Sprache: YAML (yaml)
  1. Set variable $broker to the pod name of the broker you want to resize (e.g. broker-0):
<code>broker=broker-0</code>
Code-Sprache: YAML (yaml)
  1. Delete the broker pod:
<code>kubectl delete pod $broker</code>
Code-Sprache: YAML (yaml)
  1. Increase the PVC size (replace <size> with the Kubernetes Quantity for the volume, e.g. 5Gi):
<code>kubectl patch pvc brokerdata-$broker --patch '{"spec": { "resources": {"requests": {"storage": "<size>"}}}}'</code>
Code-Sprache: YAML (yaml)
  1. Wait until the PVC shows the correct CAPACITY:
<code>kubectl get pvc brokerdata-$broker</code>
Code-Sprache: YAML (yaml)
  1. Recreate the StatefulSet:
<code>kubectl apply -f broker.yaml</code>
Code-Sprache: YAML (yaml)
  1. Wait for the StatefulSet to recreate the missing pod and wait for the StatefulSet to be ready (kubectl get sts broker shows READY 2/2 or higher, but same number on both sides of the slash)
  2. Verify that all cluster members show the same output for the cluster members:
kubectl get pod -lapp=broker -o name | xargs -I % kubectl exec % -- vmq-admin cluster show
Code-Sprache: YAML (yaml)
  • The output should look similar to this:
Defaulted container "broker" out of: broker, wait-for-k8s (init)
+-------------------------------------------------+---------+
| Node                                            | Running |
+-------------------------------------------------+---------+
| VerneMQ@broker-0.broker.cybus.svc.cluster.local | true    |
+-------------------------------------------------+---------+
| VerneMQ@broker-1.broker.cybus.svc.cluster.local | true    |
+-------------------------------------------------+---------+
Defaulted container "broker" out of: broker, wait-for-k8s (init)
+-------------------------------------------------+---------+
| Node                                            | Running |
+-------------------------------------------------+---------+
| VerneMQ@broker-0.broker.cybus.svc.cluster.local | true    |
+-------------------------------------------------+---------+
| VerneMQ@broker-1.broker.cybus.svc.cluster.local | true    |
+-------------------------------------------------+---------+
Code-Sprache: YAML (yaml)
  1. Repeat this step for the next broker, until all volumes are resized

Persisting through Helm values

Once you are done you should adjust your Helm values for Connectware to reflect the changes.

Update the following fields based on what volumes you resized:

PVC NameHelm value
brokerdata-broker-*global.broker.storage.data.size
brokerlog-broker-*global.broker.storage.log.size
brokerdata-control-plane-broker-*global.controlPlaneBroker.storage.data.size
brokerlog-control-plane-broker-*global.controlPlaneBroker.storage.log.size
Was this article helpful?
YesNo
Need more help?

Can’t find the answer you’re looking for?
Don’t worry, we’re here to help.

Share this article
  • Previous

    Variables Used in the Code Examples (Kubernetes)

  • Configuring Core Services (Kubernetes)

Ihr Browser unterstützt diese Webseite nicht.

Liebe Besucher:innen, Sie versuchen unsere Website über den Internet Explorer zu besuchen. Der Support für diesen Browser wurde durch den Hersteller eingestellt, weshalb er moderne Webseiten nicht mehr richtig darstellen kann.
Um die Inhalte dieser Website korrekt anzeigen zu können, benötigen Sie einen modernen Browser.

Unter folgenden Links finden Sie Browser, für die unsere Webseite optimiert wurde:

Google Chrome Browser herunterladen Mozilla Firefox Browser herunterladen

Sie können diese Website trotzdem anzeigen lassen, müssen aber mit erheblichen Einschränkungen rechnen.

Diese Website trotzdem anzeigen.