It is possible to load a RabbitMQ definitions file to configure RabbitMQ. Follow the steps below:
Store the JSON as a Kubernetes secret, because definitions may contain RabbitMQ credentials. Within the secret's data, choose a key name that corresponds with the desired load definitions filename (such as load_definition.json) and use the JSON object as the value.
Here is an example of one such secret:
apiVersion: v1
kind: Secret
metadata:
name: rabbitmq-load-definition
type: Opaque
stringData:
load_definition.json: |-
{
"users": [
{
"name": "user",
"password": "CHANGEME",
"tags": "administrator"
}
],
"vhosts": [
{
"name": "/"
}
]
}
Any load definitions specified become available within the container at /app.
NOTE: Loading a definition will take precedence over any configuration done through Helm values.
If needed, use extraSecrets to let the chart create the secret. With this approach, there is no need to manually create it before deploying a release. These secrets can also be templated to use supplied chart values. Here is an example:
auth:
password: CHANGEME
extraSecrets:
load-definition:
load_definition.json: |
{
"users": [
{
"name": "{{ .Values.auth.username }}",
"password": "{{ .Values.auth.password }}",
"tags": "administrator"
}
],
"vhosts": [
{
"name": "/"
}
]
}
loadDefinition:
enabled: true
existingSecret: load-definition
extraConfiguration: |
load_definitions = /app/load_definition.json