Skip to content

Commit

Permalink
Set up rabbitmqadmin automatically (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkuratczyk committed Oct 28, 2020
1 parent 6fc47e6 commit 3cba654
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion internal/resource/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,11 @@ func (builder *StatefulSetBuilder) podTemplateSpec(annotations, labels map[strin
"&& chmod 600 /var/lib/rabbitmq/.erlang.cookie ; " +
"cp /tmp/rabbitmq-plugins/enabled_plugins /operator/enabled_plugins " +
"&& chown 999:999 /operator/enabled_plugins ; " +
"chgrp 999 /var/lib/rabbitmq/mnesia/",
"chgrp 999 /var/lib/rabbitmq/mnesia/ ; " +
"echo '[default]' > /var/lib/rabbitmq/.rabbitmqadmin.conf " +
"&& sed -e 's/default_user/username/' -e 's/default_pass/password/' /tmp/default_user.conf >> /var/lib/rabbitmq/.rabbitmqadmin.conf " +
"&& chown 999:999 /var/lib/rabbitmq/.rabbitmqadmin.conf " +
"&& chmod 600 /var/lib/rabbitmq/.rabbitmqadmin.conf",
},
Resources: corev1.ResourceRequirements{
Limits: map[corev1.ResourceName]k8sresource.Quantity{
Expand Down Expand Up @@ -567,6 +571,11 @@ func (builder *StatefulSetBuilder) podTemplateSpec(annotations, labels map[strin
Name: "persistence",
MountPath: "/var/lib/rabbitmq/mnesia/",
},
{
Name: "rabbitmq-confd",
MountPath: "/tmp/default_user.conf",
SubPath: "default_user.conf",
},
},
},
},
Expand Down
11 changes: 10 additions & 1 deletion internal/resource/statefulset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,11 @@ var _ = Describe("StatefulSet", func() {
"&& chmod 600 /var/lib/rabbitmq/.erlang.cookie ; "+
"cp /tmp/rabbitmq-plugins/enabled_plugins /operator/enabled_plugins "+
"&& chown 999:999 /operator/enabled_plugins ; "+
"chgrp 999 /var/lib/rabbitmq/mnesia/",
"chgrp 999 /var/lib/rabbitmq/mnesia/ ; "+
"echo '[default]' > /var/lib/rabbitmq/.rabbitmqadmin.conf "+
"&& sed -e 's/default_user/username/' -e 's/default_pass/password/' /tmp/default_user.conf >> /var/lib/rabbitmq/.rabbitmqadmin.conf "+
"&& chown 999:999 /var/lib/rabbitmq/.rabbitmqadmin.conf "+
"&& chmod 600 /var/lib/rabbitmq/.rabbitmqadmin.conf",
),
"VolumeMounts": ConsistOf(
corev1.VolumeMount{
Expand All @@ -1009,6 +1013,11 @@ var _ = Describe("StatefulSet", func() {
Name: "persistence",
MountPath: "/var/lib/rabbitmq/mnesia/",
},
corev1.VolumeMount{
Name: "rabbitmq-confd",
MountPath: "/tmp/default_user.conf",
SubPath: "default_user.conf",
},
),
}))
})
Expand Down

0 comments on commit 3cba654

Please sign in to comment.