...
By default, there is no way to add custom annotations through helm charts for pods hence we will be using operator.templateConfigMap
to add custom annotations.
Prerequisite
Make sure to select the correct namespace where you want to deploy HiveMQ
Instructions
Generate default operator templates for configMap using the following command.
Code Block language bash $ helm template -s templates/hivemq-operator/operator-templates.yaml hivemq hivemq/hivemq-operator >> custom-template.yaml
Edit the
custom-template.yaml
which was generated by step1.You can add the annotations / other changes either in the
custom-template.yaml
change the configMap name (in example its set as )
Search for block
cluster-deployment.yaml
and inside this block look forspec
andtemplate
blockadd annotations inside metadata block
Code Block language yaml apiVersion: v1 kind: ConfigMap metadata: name: "custom-template" 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: prometheus.io/path: /metrics prometheus.io/port: "9100" prometheus.io/scrape: "true" ... spec: initContainers: - name: "init-shared" resources: ... ...
Apply the config map by using the following command
Code Block $ kubectl apply -f <your custom template yaml filename>
You can verify the created configMap and its values by using the following command
Code Block language bash $ kubectl describe configmap <configmap name>
set
templateConfigMap
config invalues.yaml
of Kubernetes operatorCode Block operator: ... templateConfigMap: <configmap name you created in step3 > ... hivemq: image: hivemq/hivemq4:k8s-4.5.2 ...
Execute helm upgrade / install the operator with the following command.
Code Block language bash $ helm upgrade --install -f values.yaml <cluster name> hivemq/hivemq-operator
Here <cluster name> is the one you have used during HiveMQ deployment while installing the helm chart.Â
Verify custom annotation with the following commands
Code Block $ kubectl get pods $ kubectl describe pods <pod name>