<p>I currently trying to deploy simple RabbitMQ cluster for my project.
So far, I found this two example that suit my needed.
<a href="https://www.linkedin.com/pulse/deploying-rabbitmq-cluster-kubernetes-part-1-darshana-dinushal/" rel="nofollow noreferrer">https://www.linkedin.com/pulse/deploying-rabbitmq-cluster-kubernetes-part-1-darshana-dinushal/</a></p>
<p><a href="https://github.com/marcel-dempers/docker-development-youtube-series/blob/master/messaging/rabbitmq/kubernetes/rabbit-statefulset.yaml" rel="nofollow noreferrer">https://github.com/marcel-dempers/docker-development-youtube-series/blob/master/messaging/rabbitmq/kubernetes/rabbit-statefulset.yaml</a></p>
<p>And since official website, articles and tutorial videos about RabbitMQ on Kubernetes are pointing to large production deployment. I only get this 2 example to follow.</p>
<p>And when I try it RabbitMQ pod is stuck on pending state while other pods are running fine. I currently use YAML files from the first example.</p>
<pre><code>kubectl describe pod rabbitmq-0
Name:           rabbitmq-0
Namespace:      default
Priority:       0
Node:           &lt;none&gt;
Labels:         app=rabbitmq
                controller-revision-hash=rabbitmq-84b847b5d5
                statefulset.kubernetes.io/pod-name=rabbitmq-0
Annotations:    &lt;none&gt;
Status:         Pending
IP:
IPs:            &lt;none&gt;
Controlled By:  StatefulSet/rabbitmq
Init Containers:
  config:
    Image:      busybox
    Port:       &lt;none&gt;
    Host Port:  &lt;none&gt;
    Command:
      /bin/sh
      -c
      cp /tmp/config/rabbitmq.conf /config/rabbitmq.conf &amp;&amp; ls -l /config/ &amp;&amp; cp /tmp/config/enabled_plugins /etc/rabbitmq/enabled_plugins
    Environment:  &lt;none&gt;
    Mounts:
      /config/ from config-file (rw)
      /etc/rabbitmq/ from plugins-file (rw)
      /tmp/config/ from config (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-ffj67 (ro)
Containers:
  rabbitmq:
    Image:       rabbitmq:3.8-management
    Ports:       4369/TCP, 5672/TCP
    Host Ports:  0/TCP, 0/TCP
    Environment:
      RABBIT_POD_NAME:         rabbitmq-0 (v1:metadata.name)
      RABBIT_POD_NAMESPACE:    default (v1:metadata.namespace)
      RABBITMQ_NODENAME:       rabbit@$(RABBIT_POD_NAME).rabbitmq.$(RABBIT_POD_NAMESPACE).svc.cluster.local
      RABBITMQ_USE_LONGNAME:   true
      RABBITMQ_CONFIG_FILE:    /config/rabbitmq
      RABBITMQ_ERLANG_COOKIE:  &lt;set to the key 'RABBITMQ_ERLANG_COOKIE' in secret 'rabbit-secret'&gt;  Optional: false
      K8S_HOSTNAME_SUFFIX:     .rabbitmq.$(RABBIT_POD_NAMESPACE).svc.cluster.local
    Mounts:
      /config/ from config-file (rw)
      /etc/rabbitmq/ from plugins-file (rw)
      /var/lib/rabbitmq from data (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-ffj67 (ro)
Conditions:
  Type           Status
  PodScheduled   False
Volumes:
  data:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  data-rabbitmq-0
    ReadOnly:   false
  config-file:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  &lt;unset&gt;
  plugins-file:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  &lt;unset&gt;
  config:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      rabbitmq-config
    Optional:  false
  kube-api-access-ffj67:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       &lt;nil&gt;
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              &lt;none&gt;
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason            Age                   From               Message
  ----     ------            ----                  ----               -------
  Warning  FailedScheduling  2m25s (x39 over 89m)  default-scheduler  0/1 nodes are available: 1 pod has unbound immediate PersistentVolumeClaims. preemption: 0/1 nodes are available: 1 Preemption is not helpful for scheduling.
</code></pre>

TaeXtreme
<p>Since I had tested deploying RabbitMQ via docker-compose and it worked before.</p>
<p>I discovered a tool called Kompose and I use it to convert my rabbitmq docker-compose file to k8s yaml files.</p>
<p>And it works!.</p>
<p>Yaml files that generate from Kompose.</p>
<p>service file</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.version: 1.26.0 (40646f47)
  labels:
    io.kompose.service: rabbitmq3
  name: rabbitmq3
spec:
  type: LoadBalancer
  ports:
    - name: amqp
      port: 5672
      targetPort: 5672
    - name: discovery
      port: 15672
      targetPort: 15672
  selector:
    io.kompose.service: rabbitmq3
</code></pre>
<p>deployment file</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.version: 1.26.0 (40646f47)
  labels:
    io.kompose.service: rabbitmq3
  name: rabbitmq3
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: rabbitmq3
  strategy: { }
  template:
    metadata:
      annotations:
        kompose.cmd: kompose convert
        kompose.version: 1.26.0 (40646f47)
      labels:
        io.kompose.service: rabbitmq3
    spec:
      containers:
        - env:
            - name: RABBITMQ_DEFAULT_PASS
              value: rabbitpassword
            - name: RABBITMQ_DEFAULT_USER
              value: rabbituser
          image: rabbitmq:management-alpine
          name: rabbitmq
          ports:
            - containerPort: 15672
              name: discovery
            - containerPort: 5672
              name: amqp
          resources: { }
      restartPolicy: Always
</code></pre>
