<p>I have developed Spring Boot applications. I have setup admin and RabbitMQ as well as spring cloud bus. When i refresh the end points of applications, it refreshes the properties for application. </p>

<p>Can anyone please help me how to setup RabbitMQ in kubernetes now? I did research to an extent and found in few articles that it needs to be deployed as "Statefulset" rather than "Deployment" <a href="https://notallaboutcode.blogspot.de/2017/09/rabbitmq-on-kubernetes-container.html" rel="nofollow noreferrer">https://notallaboutcode.blogspot.de/2017/09/rabbitmq-on-kubernetes-container.html</a>. I could not get why this needs to be done exactly. Also any useful link on deploying RabbitMQ in kubernetes would help.</p>

<p>It depends on what you're looking to do and what tools you have available. I guess your current setup is much like that described in  <a href="http://www.baeldung.com/spring-cloud-bus" rel="nofollow noreferrer">http://www.baeldung.com/spring-cloud-bus</a>. One approach to porting that to kubernetes might be to try to get your setup working with docker-compose first and then you could port that docker-compose to kubernetes deployment descriptors. </p>

<p>A simple way to deploy rabbitmq in k8s would be to set up a Deployment using a rabbitmq docker image. An example of this is <a href="https://github.com/Activiti/activiti-cloud-examples/blob/fe732096b5a19de0ad44879a399053f6ae02b095/kubernetes/kubectl/infrastructure.yml#L17" rel="nofollow noreferrer">https://github.com/Activiti/activiti-cloud-examples/blob/fe732096b5a19de0ad44879a399053f6ae02b095/kubernetes/kubectl/infrastructure.yml#L17</a>. (Notice that file isn't radically different from a docker-compose file so you could port from one to the other.) But that won't be persisting data outside of the Pods so if the cluster were to go down or the Pod/s were to go down then you'd lose message data. The persistence is ephemeral.</p>

<p>So to have non-ephemeral persistence you could instead use a StatefulSet as in the example you point to. Another example is <a href="https://wesmorgan.svbtle.com/rabbitmq-cluster-on-kubernetes-with-statefulsets" rel="nofollow noreferrer">https://wesmorgan.svbtle.com/rabbitmq-cluster-on-kubernetes-with-statefulsets</a> </p>

<p>If you are using helm (or can use helm) then you could use the <a href="https://hub.kubeapps.com/charts/stable/rabbitmq" rel="nofollow noreferrer">rabbitmq helm chart</a>, <a href="https://github.com/kubernetes/charts/blob/master/stable/rabbitmq/templates/statefulset.yaml#L2" rel="nofollow noreferrer">which uses a StatefulSet</a>. </p>

<p>But if your only reason for needing the bus is to trigger refreshes when property changes happen then there are alternative paths available with Kubernetes. I'm guessing you need the hot reloads so you could look at using <a href="https://github.com/fabric8io/spring-cloud-kubernetes#propertysource-reload" rel="nofollow noreferrer">https://github.com/fabric8io/spring-cloud-kubernetes#propertysource-reload</a> Or if you need the config to come from git specifically then you could look at <a href="http://fabric8.io/guide/develop/configuration.html" rel="nofollow noreferrer">http://fabric8.io/guide/develop/configuration.html</a> (If you didn't need the hot reloads or git then you could consider versioning your configmaps and upgrading them with your application upgrades like in <a href="https://dzone.com/articles/configuring-java-apps-with-kubernetes-configmaps-a" rel="nofollow noreferrer">https://dzone.com/articles/configuring-java-apps-with-kubernetes-configmaps-a</a> )</p>
