k8s局域网通过operator部署rabbitmq

参考: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

参考网站

k8s部署RabbitMQ Operator - 知乎

遇到问题及解决

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

删除成功

相关推荐
陈文锦丫1 天前
MQ的学习
java·开发语言
liwulin05061 天前
【PYTHON-YOLOV8N】如何自定义数据集
开发语言·python·yolo
青蛙大侠公主1 天前
Thread及其相关类
java·开发语言
爱吃大芒果1 天前
Flutter 主题与深色模式:全局样式统一与动态切换
开发语言·javascript·flutter·ecmascript·gitcode
云栖梦泽1 天前
易语言数据库操作:结构化数据管理的核心
开发语言
上海蓝色星球1 天前
迈向智慧电网新纪元:上海蓝色星球数字孪生变电主子站系统
运维·数据库
电子硬件笔记1 天前
Python语言编程导论第七章 数据结构
开发语言·数据结构·python
南棱笑笑生1 天前
20251217给飞凌OK3588-C开发板适配Rockchip原厂的Buildroot【linux-5.10】后调通ov5645【只能预览】
linux·c语言·开发语言·rockchip
ulias2121 天前
C++ 的容器适配器——从stack/queue看
开发语言·c++