How to upgrade HiveMQ and Operator versions
This article explains how to upgrade HiveMQ and Operator from older versions to newer ones without downtime.
Mandatory Custom Resource Definition Update
Since HiveMQ 4.7, the HiveMQ Kubernetes Operator supports the stable v1 api version of CustomResourceDefinition. Use of the v1 CustomResourceDefinition requires a mandatory update of your CRD. The update does not require any downtime.
Prerequisites:
k8s version 1.16+ and < 1.25 is installed
Helm version 3 is installed
Hivemq k8s operator chart version < 0.9.0. You can verify this using
helm list
command
Instructions
Since Hivemq Operator CRD was updated with HiveMQ 4.7.0 release. The first step is to upgrade HiveMQ to the max version before the 4.7.0 version i.e. 4.6.12 version.
Edit your HiveMQ
values.yaml
to update the HiveMQ image
Refer to the following example:hivemq: image: hivemq/hivemq4:k8s-4.6.12
Refer Upgrade guide and make changes in your
value.yaml
if any is recommended. For example, if you are upgrading from 4.5.x to 4.6.12 then check HiveMQ 4.5 to 4.6 guide etc. This will make sure you do not miss any updates and avoid unnecessary surprises.Once all changes are included in values.yaml then do a rolling upgrade
helm upgrade --install -f <values.yaml> <release name> hivemq/hivemq-operator
Once the rolling upgrade is completed, all hivemq pods will be running HiveMq 4.6.12 version. You can verify hivemq.log for confirmation.
Please verify if the broker is working as expected after this upgrade and then move to the next step.
Until now, you are using chart versions older than 0.9.0, With this step, we will be updating CRD.
You must update your CustomResourceDefinition. And this can be done without any downtime. Refer here for CHANGELOG.Update helm repository
helm repo update
Simply apply the new CRD using the following command (considering)
k8s version is 1.16+. The Helm Chart now uses v1 CustomResourceDefinition by default. This is only supported in Kubernetes 1.16+.
Scale the operator to 0 so it doesn’t immediately reconcile. This will only remove the operator pod, but leave the HiveMQ nodes as remaining.
With help of the following command, you can get the operator depoyment name
Scale down the operator pod.
Now, the pod’s list has only hivemq pods.
Edit hivemq operator
values.yaml
update the hivemq version for example to 4.7.12. Refer to the following example:
Refer Upgrade guide and make sure to do changes in your
value.yaml
if any is recommended. This will make sure you do not miss any updates and avoid unnecessary surprises.Once all changes are included in values.yaml then do a rolling upgrade
After the rolling upgrade, the hivemq operator pod will be added with the new chart version. You can verify this with the following command, and check the CHART. It should be
hivemq-operator-0.11.6
Once the rolling upgrade is completed, all hivemq pods will be running HiveMq 4.7.12 version. You can verify hivemq.log for confirmation.
Please verify if the broker is working as expected after this upgrade
Repeat step 4 until you reach to latest hivemq version.
We highly recommend to perform testing on stagging or testing environment before moving to production.