参考:Installing RabbitMQ Cluster Operator in a Kubernetes Cluster | RabbitMQ
1、下载cluster-operator.yml
wget https://github.com/rabbitmq/cluster-operator/releases/download/v2.7.0/cluster-operator.yml
2、拉取对应的镜像,这里的版本是根据github发布的版本确定(如上图https://github.com/rabbitmq/cluster-operator/releases):
docker pull rabbitmqoperator/cluster-operator:2.7.0
3、导出镜像:
docker save rabbitmqoperator/cluster-operator:2.7.0 | gzip > rabbitmq-cluster-operator_v2.7.0.tar.gz
4、将镜像和cluster-operator.yml传输到局域网:
scp -P10022 rabbitmq-cluster-operator_v2.7.0.tar.gz root@ip:/data/
scp -P10022 cluster-operator.yml root@ip:/data/
5、进入局域网服务器,将镜像导入并且上传:
docker load -i rabbitmq-cluster-operator_v2.7.0.tar.gz
docker tag 2324be6c5743ad72bedb72bec9beaf989bd5bace9ed49992566ee2bcda03dcdd harbor.xxx.com:10443/rabbitmqoperator/cluster-operator:2.7.0
docker push harbor.xxx.com:10443/rabbitmqoperator/cluster-operator:2.7.0
6、修改cluster-operator.yml
找到下面的内容:
image: rabbitmqoperator/cluster-operator:2.7.0
name: operator
换成:
image: harbor.xxx.com:10443/rabbitmqoperator/cluster-operator:2.7.0
name: operator
7、通过下面命令执行创建:
kubectl apply -f cluster-operator.yml
执行后会创建namespace rabbitmq-system。可以通过下面方式查看:
kubectl get all -n rabbitmq-system
8、进入yaml文件的目录,rabbitmq.yaml的文件内容如下:
apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
name: rabbitmq-release
namespace: rabbitmq-system
labels:
app: rabbitmq-release
spec:
replicas: 3
image: "harbor.xxx.com:10443/xxx-apps/rabbitmq:3.12.13-debian-12-r2"
resources:
requests:
cpu: 5000m
memory: 10Gi
limits:
cpu: 8000m
memory: 10Gi
persistence:
storageClassName: "xsky-iscsi-sc"
storage: 20Gi
rabbitmq:
additionalConfig: |
default_vhost = vhost #配置Virtual Hosts
default_user = barn #配置登录账号
default_pass = barn #配置账号密码
9、执行创建,完成rabbitmq的创建:
kubectl apply -f rabbitmq.yaml -n rabbitmq-system
10,如果需要卸载,执行下面命令:
kubectl delete -f rabbitmq.yaml -n rabbitmq-system
参考网站
遇到问题及解决
kubectl delete -f rabbitmq.yaml
执行以上命令失败,报下面错误:
Error from server (NotFound): error when deleting "rabbitmq.yaml": rabbitmqclusters.rabbitmq.com "helloworld" not found
原因:删除的时候没有指定namespace。
kubectl delete -f rabbitmq.yaml -n rabbitmq-system
删除成功