k8s局域网通过operator部署rabbitmq

本文详细介绍了如何下载并配置RabbitMQClusterOperator在Kubernetes集群中的安装过程,包括镜像拉取、yaml文件修改、部署和删除操作,以及解决删除时的Namespace问题。
摘要由CSDN通过智能技术生成

参考: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
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值