Create Instance

RabbitMQ is a popular message queue middleware that features an efficient and reliable message asynchronous delivery mechanism. It is mainly used for data exchange and transmission between different systems and has a wide range of applications in various fields such as enterprise solutions, financial payments, telecommunications, e-commerce, social networking, instant messaging, video, the Internet of Things, and vehicle networking.

In the current version, the following versions of RabbitMQ are supported: 3.8.16 and 3.12. When creating an instance, only these two versions can be selected. The instance creation process will use 3.12 as an example.

Version Suggestion

When selecting a version, it is recommended to choose the latest supported version. 3.12 has the following advantages:

  1. 3.12 supports production-ready quorum queues; additionally, the community has fixed many bugs, and performance has greatly improved in 3.12.
  2. 3.8.x will be gradually phased out. If you are currently using the 3.8.x series and later require version upgrades, it may impact business operations.

Create RabbitMQ Instance

Prerequisites

  • Please ensure that there is an available storage class in the current cluster and that there is sufficient available space.

Procedure

CLI
Web Console

Create a RabbitMQ instance via CLI:

$ cat << EOF | kubectl -n default create -f -
apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
  name: rrrr
spec:
  affinity:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        - labelSelector:
            matchLabels:
              app.kubernetes.io/name: cluster-in
          topologyKey: kubernetes.io/hostname
  persistence:
    storage: 1Gi
    storageClassName: sc-topolvm
  rabbitmq:
    additionalConfig: |-
      channel_max=1000
      cluster_keepalive_interval=10000
      collect_statistics=none
      collect_statistics_interval=5000
      default_vhost=/
      delegate_count=16
      disk_free_limit.absolute=50MB
      handshake_timeout=10000
      heartbeat=60
      max_message_size=134217728
      mirroring_sync_batch_size=4096
      mnesia_table_loading_retry_limit=10
      mnesia_table_loading_retry_timeout=30000
      num_acceptors.tcp=10
      queue_index_embed_msgs_below=4096
      raft.wal_max_size_bytes=64000000
      vm_memory_calculation_strategy=allocated
      vm_memory_high_watermark.relative=0.4
      vm_memory_high_watermark_paging_ratio=0.5
  replicas: 3
  resources:
    limits:
      cpu: 1
      memory: 2Gi
    requests:
      cpu: 1
      memory: 2Gi
  service:
    type: ClusterIP
  upgradeOption:
    autoUpgrade: false
  version: "3.12"
EOF

For detailed field information, please refer to RabbitMQ API Documentation.

After the instance is created, you can view the instance with the following command:

$ kubectl -n default get rabbitmqclusters
NAME   AGE
rrrr   74s

You can use the following custom command to view the status of the instances in bulk:

$ kubectl -n default get rabbitmqclusters rrrr -o custom-columns='NAME:.metadata.name,PHASE:.status.phase,USER SECRET:.status.defaultUser.secretReference.name'
NAME   PHASE    USER SECRET
rrrr   Active   rrrr-default-user

The meaning of the output table fields is as follows:

FieldDescription
NAMEInstance name
PHASEInstance status, which can be in the following states:
  • Creating: The instance is creating resources and initializing the cluster
  • Updating: The instance configuration is being updated
  • Active: The instance is in service status
  • Failed: The instance encountered an error during initialization or update
  • Unknown: The instance is in an unrecognized state
  • Paused: The instance is paused and the related Pods have been shut down
USER SECRETSecret that stores the default user account information
Tip

For the connection methods of business applications accessing RabbitMQ instances, please refer to Select Connection Address and Configure Connection Method.