Le0n
Le0n

Reputation: 37

RabbitMQ cluster-operator does not work in Kubernetes

RabbitMQ cluster operator does not work in Kubernetes.
I have a kubernetes cluster 1.17.17 of 3 nodes. I deployed it with a rancher. According to this instruction I installed RabbitMQ cluster-operator: https://www.rabbitmq.com/kubernetes/operator/quickstart-operator.html
kubectl apply -f "https://github.com/rabbitmq/cluster-operator/releases/latest/download/cluster-operator.yml"
Its ok! but.. I have created this very simple configuration for the instance according to the documentation:

apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
  name: rabbitmq
  namespace: test-rabbitmq

I have error:error while running "VolumeBinding" filter plugin for pod "rabbitmq-server-0": pod has unbound immediate PersistentVolumeClaims

after that i checked:
kubectl get storageclasses
and saw that there were no resources! I added the following storegeclasses:

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer

create pv and pvc:

kind: PersistentVolume
apiVersion: v1
metadata:
  name: rabbitmq-data-sigma
  labels:
    type: local
  namespace: test-rabbitmq
  annotations:
    volume.alpha.kubernetes.io/storage-class: rabbitmq-data-sigma
spec:
  storageClassName: local-storage
  capacity:
    storage: 3Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Recycle
  hostPath:
    path: "/opt/rabbitmq-data-sigma"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: rabbitmq-data
  namespace: test-rabbitmq
spec:
  storageClassName: local-storage
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 3Gi

I end up getting an error in the volume - which is being generated automated: enter image description here

FailedBinding   no persistent volumes available for this claim and no storage class is set  

please help to understand this problem!

Upvotes: 0

Views: 3246

Answers (1)

matt_j
matt_j

Reputation: 4614

You can configure Dynamic Volume Provisioning e.g. Dynamic NFS provisioning as describe in this article or you can manually create PersistentVolume ( it is NOT recommended approach).

I really recommend you to configure dynamic provisioning - this will allow you to generate PersistentVolumes automatically.

Manually creating PersistentVolume

As I mentioned it isn't recommended approach but it may be useful when we want to check something quickly without configuring additional components.

First you need to create PersistentVolume:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Recycle
  hostPath:
    path: /mnt/rabbitmq # data will be stored in the "/mnt/rabbitmq" directory on the worker node
    type: Directory

And then create the /mnt/rabbitmq directory on the node where the rabbitmq-server-0 Pod will be running. In your case you have 3 worker node so it may difficult to determine where the Pod will be running.

As a result you can see that the PersistentVolumeClaim was bound to the newly created PersistentVolume and the rabbitmq-server-0 Pod was created successfully:

# kubectl get pv,pvc -A
NAME                   CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                                         STORAGECLASS   REASON   AGE
persistentvolume/pv    10Gi       RWO            Recycle          Bound    test-rabbitmq/persistence-rabbitmq-server-0                           11m


NAMESPACE       NAME                                                  STATUS   VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
test-rabbitmq   persistentvolumeclaim/persistence-rabbitmq-server-0   Bound    pv       10Gi       RWO                           11m

# kubectl get pod -n test-rabbitmq
NAME                READY   STATUS    RESTARTS   AGE
rabbitmq-server-0   1/1     Running   0          11m

Upvotes: 1

Related Questions