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

删除成功

相关推荐
Asthenia041226 分钟前
Spring扩展点与工具类获取容器Bean-基于ApplicationContextAware实现非IOC容器中调用IOC的Bean
后端
bobz96544 分钟前
ovs patch port 对比 veth pair
后端
Asthenia04121 小时前
Java受检异常与非受检异常分析
后端
uhakadotcom1 小时前
快速开始使用 n8n
后端·面试·github
JavaGuide1 小时前
公司来的新人用字符串存储日期,被组长怒怼了...
后端·mysql
bobz9651 小时前
qemu 网络使用基础
后端
Asthenia04122 小时前
面试攻略:如何应对 Spring 启动流程的层层追问
后端
Asthenia04122 小时前
Spring 启动流程:比喻表达
后端
Asthenia04122 小时前
Spring 启动流程分析-含时序图
后端
ONE_Gua2 小时前
chromium魔改——CDP(Chrome DevTools Protocol)检测01
前端·后端·爬虫