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
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
Edit the
custom-template.yaml
to incorporate your changes which was generated by step 1apiVersion: 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 }}"
Apply the config map by using the following command
$ kubectl apply -f <your custom template yaml filename>
Set templateConfigMap config in
values.yaml
of Kubernetes operatorExecute helm upgrade / install the operator with the following command.
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.
Deploy HiveMQ cluster with the following command
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.