部署RabbitMQ Cluster Operator
1
| kubectl apply -f https://github.com/rabbitmq/cluster-operator/releases/latest/download/cluster-operator.yml
|
部署RabbitMQ cluster
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| tee rabbitmq.yaml << EOF
apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
name: rabbitmq
spec:
rabbitmq:
additionalConfig: |
default_user=guest
default_pass=guest
replicas: 3
image: rabbitmq:3.8-management
service:
type: NodePort
persistence:
storageClassName: nfs-client
storage: 100Gi
EOF
kubectl apply -f rabbitmq.yaml
#查出NodePort端口
#kubectl get svc/rabbitmq
kubectl get service/rabbitmq -o jsonpath="{.spec.ports[0].nodePort}"
|
负载测试
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| #如果部署集群时未配置用户名密码
#username="$(kubectl get secret rabbitmq-default-user -o jsonpath='{.data.username}' | base64 --decode)"
#password="$(kubectl get secret rabbitmq-default-user -o jsonpath='{.data.password}' | base64 --decode)"
username=guest
password=guest
service="$(kubectl get service rabbitmq -o jsonpath='{.spec.clusterIP}')"
kubectl run perf-test --image=pivotalrabbitmq/perf-test -- --uri amqp://$username:$password@$service
kubectl logs --follow perf-test
#删除测试的pod
kubectl delete pod perf-test
|
https://www.rabbitmq.com/kubernetes/operator/quickstart-operator.html
https://github.com/rabbitmq/cluster-operator/blob/main/docs/examples/production-ready/rabbitmq.yaml
https://github.com/rabbitmq/cluster-operator/tree/main/docs/examples/set-login-password-username