rabbitmq_k8s

rabbitmq_k8s

“选了官方支持的最接近的3.10.8”
在k8s集群上通过helm部署rabbitmq3.7.13

3节点集群
使用nodeport模式
部署命令使用helm upgrade –install
namespace等其他参数都尽量在helm安装命令里指定
命令可复用(兼容install和upgrade场景)

ENV

k8s 1.24.6
dcoker 25.0.5
helm 3.19.2

helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
收集values有助于判断正确的参数设置:
helm show values bitnami/rabbitmq –version 10.3.9
NAME CHART VERSION APP VERSION DESCRIPTION
bitnami/rabbitmq 10.3.9 3.10.8 RabbitMQ is an open source general-purpose mess…
bitnami/rabbitmq 10.3.8 3.10.8 RabbitMQ is an open source general-purpose mess…

先确认存在对应版本image:
https://hub.docker.com/_/rabbitmq/tags
找到:docker pull rabbitmq:3.10.8-management-alpine

helm upgrade –install rabbitmq \
–namespace rabbitmq \
–create-namespace \
–version 10.3.9 \
–set replicaCount=3 \
–set service.type=NodePort \
–set service.managerService.type=NodePort \
–set persistence.size=50Gi \
–set auth.username=admin \
–set auth.password=Rabbitmq@2026 \
–set resources.requests.cpu=200m \
–set resources.requests.memory=256Mi \
–set podAntiAffinityPreset=soft \
–set image.repository=rabbitmq \
–set image.tag=3.10.8-management-alpine \
–set volumePermissions.enabled=false \
bitnami/rabbitmq

回退删除命令
helm uninstall rabbitmq -n rabbitmq; kubectl delete pvc -n rabbitmq –all; kubectl delete ns rabbitmq

连接使用

root@k8s-pre-31:/igo/soft/rabbitmq# kg svc -n rabbitmq
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
rabbitmq NodePort 10.96.1.125 5672:30875/TCP,4369:30871/TCP,25672:30063/TCP,15672:30126/TCP 2m23s
rabbitmq-headless ClusterIP None 4369/TCP,5672/TCP,25672/TCP,15672/TCP 2m23s

管理后台
http://10.80.238.31:30126 guest/guest admin/Rabbitmq@2026
内部链接
rabbitmq.rabbitmq.svc.cluster.local:5672
外部连接
amqp://admin:Rabbitmq@2026@10.80.238.31:30875/

OUTPUT

NAME: rabbitmq
LAST DEPLOYED: Sun Apr 12 13:44:52 2026
NAMESPACE: rabbitmq
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: rabbitmq
CHART VERSION: 10.3.9
APP VERSION: 3.10.8** Please be patient while the chart is being deployed **

Credentials:
    echo "Username      : admin"
    echo "Password      : $(kubectl get secret --namespace rabbitmq rabbitmq -o jsonpath="{.data.rabbitmq-password}" | base64 -d)"
    echo "ErLang Cookie : $(kubectl get secret --namespace rabbitmq rabbitmq -o jsonpath="{.data.rabbitmq-erlang-cookie}" | base64 -d)"

Note that the credentials are saved in persistent volume claims and will not be changed upon upgrade or reinstallation unless the persistent volume claim has been deleted. If this is not the first installation of this chart, the credentials may not be valid.
This is applicable when no passwords are set and therefore the random password is autogenerated. In case of using a fixed password, you should specify it when upgrading.
More information about the credentials may be found at https://docs.bitnami.com/general/how-to/troubleshoot-helm-chart-issues/#credential-errors-while-upgrading-chart-releases.

RabbitMQ can be accessed within the cluster on port 5672 at rabbitmq.rabbitmq.svc.cluster.local

To access for outside the cluster, perform the following steps:

Obtain the NodePort IP and ports:

    export NODE_IP=$(kubectl get nodes --namespace rabbitmq -o jsonpath="{.items[0].status.addresses[0].address}")
    export NODE_PORT_AMQP=$(kubectl get --namespace rabbitmq -o jsonpath="{.spec.ports[?(@.name=='amqp')].nodePort}" services rabbitmq)
    export NODE_PORT_STATS=$(kubectl get --namespace rabbitmq -o jsonpath="{.spec.ports[?(@.name=='http-stats')].nodePort}" services rabbitmq)

To Access the RabbitMQ AMQP port:

    echo "URL : amqp://$NODE_IP:$NODE_PORT_AMQP/"

To Access the RabbitMQ Management interface:

    echo "URL : http://$NODE_IP:$NODE_PORT_STATS/"

igozhang 2021