Set custom variables using Kubernetes Legacy HiveMQ operator

This artical explains how to set custom variables using the Kubernetes operator. custom variables are nothing but additional properties specified in HiveMQCluster specification.

With the help of operator.templateConfigMap and controllerTemplate we can set custom variables.

Let's take the example of setting custom annotations with help of a custom variable.

Instructions

  1. Generate default operator templates for configMap using the following steps.

    • $ helm template -s templates/hivemq-operator/operator-templates.yaml hivemq hivemq/hivemq-operator >> custom-template.yaml
  2. Edit the custom-template.yaml to incorporate your changes which was generated by step 1

    • apiVersion: v1 kind: ConfigMap metadata: name: <your custom template name> data: cluster-daemon-set.yaml: |- ... cluster-deployment.yaml: |- apiVersion: apps/v1 kind: Deployment metadata: name: "{{ spec.name }}" namespace: "{{ spec.namespace }}" ... spec: minReadySeconds: 30 ... template: metadata: labels: app: "hivemq" hivemq-cluster: "{{ spec.name }}" hivemq.com/node-offline: "false" annotations: mycustomValue: "{{ spec.customProperties.myCustomProperty }}"
  3. Apply the config map by using the following command

    • $ kubectl apply -f <your custom template yaml filename>
  4. Set templateConfigMap config in values.yaml of Kubernetes operator

  5. Execute helm upgrade / install the operator with the following command.

  6. Add custom controller template in HiveMQ cluster yaml. This will refer to the custom template which was created and configured in step 1 and step 2 respectively.

  7. Deploy HiveMQ cluster with the following command

  8. You can check your changes are applied correctly or not by executing the following command


    • The output of the describe command will include changes.
      Please refer following output as an example.