Charts: [rabbitmq] how to add vhost automation after rabbitmq set up

Created on 27 Oct 2020  路  6Comments  路  Source: bitnami/charts

i'm very sorry to ask questions in issues. but i didn鈥檛 find a better place to ask you questions directly.

I don't know how to add vhost automation when i use helm install by bitnami/rabbitmq. this only need two simple command:

rabbitmqctl add_vhost aid-recommend
rabbitmqctl set_permissions -p aid-recommend pax-recomm ".*" ".*" ".*"

what's best practice for my need?

Most helpful comment

ok, i will create a PR for this following days.

All 6 comments

Hi @nonpool,

Don't worry, this is exactly the place! I would say that connecting to the rabbitmq container would be the easier way. The needed commands would be similar to:

kubectl exec <rabbitmq_pod_name> --container rabbitmq -- rabbitmqctl add_vhost aid-recommend
kubectl exec <rabbitmq_pod_name> --container rabbitmq -- rabbitmqctl set_permissions -p aid-recommend pax-recomm ".*" ".*" ".*"

You could also try to add this configuration using the HTTP API if you can't exec the pod.

@FraPazGal
Thank you very much, the way I add vhost now is as you said. But what i want is automate this process in some way. I need to deploy rabbitmq in many different k8s clusters.
And i try to add the to command to command in values.yaml, like:

command: [
    "/opt/bitnami/scripts/rabbitmq/entrypoint.sh",
    "/opt/bitnami/scripts/rabbitmq/run.sh",
    "rabbitmqctl add_vhost aid-recommend",
    "rabbitmqctl set_permissions -p aid-recommend pax-recomm \".*\" \".*\" \".*\""
]

but this way is not work well.

Hi @nonpool,

Sorry, I misread your question. Yes, using command would not work as run.sh starts the rabbitmq-server process in that shell. I looked into adding new vhosts and users to the config file but I couldn't find any info of the official documentation. It only described how to configure the default user/vhost, but I think that should be enough to solve this. Please try defining auth.username=pax-reomm and adding the following to extraConfiguration in values.yaml:

auth:
  username: pax-recomm
extraConfiguration: |-
  default_vhost = aid-recommend
  default_permissions.configure = .*
  default_permissions.read = .*
  default_permissions.write = .*

@FraPazGal
Great! Perfectly solved my problem.
I think this should be added to the README to help more user. Because changing the default user/vhost is really useful.

Happy to help! I agree with you. If you want, feel free to create a PR adding a section to our README and we would review and merge it. If not, I'll update it in the following days!

ok, i will create a PR for this following days.

Was this page helpful?
0 / 5 - 0 ratings