• helm 安装 RabbitMQ 集群


    资源清单

    本文安装 rabbitmq 依赖 K8S集群helm ,本文不提供 K8S集群helm 安装方式

    使用此文档部署,需要自行解决 storageClass 问题 ( NFS, ceph, openebs等 )

    使用此文档部署,需要自行解决 ingress nginx 问题,部署服务会定义ingress nginx ( 也可以不启用 ingress,使用 NodePort 进行访问 )

    软件 版本
    chart 9.0.8
    rabbitmq 3.9.17
    kubernetes v1.19.3
    helm v3.8.1
    ingress nginx 3.15.2

    helm 安装 rabbitmq 集群

    1. 添加 rabbitmq helm 仓库

    $ helm repo add bitnami https://charts.bitnami.com/bitnami
    

    2. 查询 rabbitmq 资源

    $ helm repo update
    
    $ helm search repo rabbitmq
    NAME                             	CHART VERSION	APP VERSION 	DESCRIPTION                                       
    bitnami/rabbitmq                 	9.0.8        	3.9.17      	RabbitMQ is an open source general-purpose mess...
    

    3. 拉取 rabbitmq chart 到本地

    $ mkdir /root/rabbitmq && cd /root/rabbitmq
    
    # 拉取 chart 到本地 /root/rabbitmq 目录
    $ helm pull bitnami/rabbitmq --version 9.0.8
    
    $ tar -xvf rabbitmq-9.0.8.tgz
    $ cp rabbitmq/values.yaml ./values-test.yaml
    
    # 查看当前目录层级
    $ tree -L 2
    .
    ├── rabbitmq
    │   ├── Chart.lock
    │   ├── charts
    │   ├── Chart.yaml
    │   ├── README.md
    │   ├── templates
    │   ├── values.schema.json
    │   └── values.yaml
    ├── rabbitmq-9.0.8.tgz
    └── values-test.yml
    

    4. 对本地 values-test.yaml 修改

    • 查看集群 storageclasses
    $ kubectl get storageclasses.storage.k8s.io 
    NAME                   PROVISIONER           RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
    openebs-jiva-default   jiva.csi.openebs.io   Delete          Immediate              true                   33d
    
    • 修改配置

    如需定义其他配置,可以查看 rabbitmq/values.yaml 文件配置,然后复制到 values-test.yaml 中进行定义

    $ cat values-test.yaml 
    
    ## 全局配置定义 storageClass: "",会使用集群配置的 openebs 提供的 storageClass,
    ## 使用此文档部署,需要自行解决 storageClass 问题 (ceph, nfs, 公有云提供的 nfs)
    
    # 全局定义:定义 storageClass
    global:
      storageClass: "openebs-jiva-default"
    
    # 定义登陆 web 界面的账号定义
    auth:
      username: admin
      password: "admin123"
    
    # 需要额外插件
    plugins: "rabbitmq_management rabbitmq_peer_discovery_k8s"
    extraPlugins: "rabbitmq_auth_backend_ldap"
    
    # 定义集群
    clustering:
      enabled: true
      addressType: hostname
    
    # 定义容器端口
    containerPorts:
      amqp: 5672
      amqpTls: 5671
      dist: 25672
      manager: 15672
      epmd: 4369
      metrics: 9419
    
    # 定义集群中服务个数
    replicaCount: 3
    
    # 定义 pv pvc 
    persistence:
      enabled: true
      size: 10Gi
    
    #定义 Ingress 信息
    ingress:
      enabled: true
      path: /
      pathType: ImplementationSpecific
      hostname: rabbitmq.evescn.com
    

    5. 安装 rabbitmq 集群

    # 创建 test-middleware 名称空间
    $ kubectl create ns test-middleware
    
    # 安装 rabbitmq 集群
    $ helm -n test-middleware install rabbitmq-cluster rabbitmq -f values-test.yaml
    
    ## helm -n NAMESAPCE install SERVER_NAME FILE_NAME -f CONFIG_FILE
    -n 指定 kubernetes 集群名称空间
    -f 指定使用的配置文件,文件中定义的配置可以覆盖 mysql/values.yaml 文件中配置
    
    
    NAME: rabbitmq-cluster
    LAST DEPLOYED: Sat May 14 22:37:15 2022
    NAMESPACE: test-middleware
    STATUS: deployed
    REVISION: 1
    TEST SUITE: None
    NOTES:
    CHART NAME: rabbitmq
    CHART VERSION: 9.0.8
    APP VERSION: 3.9.17** Please be patient while the chart is being deployed **
    
    Credentials:
        echo "Username      : admin"
        echo "Password      : $(kubectl get secret --namespace test-middleware rabbitmq-cluster -o jsonpath="{.data.rabbitmq-password}" | base64 --decode)"
        echo "ErLang Cookie : $(kubectl get secret --namespace test-middleware rabbitmq-cluster -o jsonpath="{.data.rabbitmq-erlang-cookie}" | base64 --decode)"
    
    Note that the credentials are saved in persistent volume claims and will not be changed upon upgrade or reinstallation unless the persistent volume claim has been deleted. If this is not the first installation of this chart, the credentials may not be valid.
    This is applicable when no passwords are set and therefore the random password is autogenerated. In case of using a fixed password, you should specify it when upgrading.
    More information about the credentials may be found at https://docs.bitnami.com/general/how-to/troubleshoot-helm-chart-issues/#credential-errors-while-upgrading-chart-releases.
    
    RabbitMQ can be accessed within the cluster on port  at rabbitmq-cluster.test-middleware.svc.cluster.local
    
    To access for outside the cluster, perform the following steps:
    
    To Access the RabbitMQ AMQP port:
    
    1. Create a port-forward to the AMQP port:
    
        kubectl port-forward --namespace test-middleware svc/rabbitmq-cluster 5672:5672 &
        echo "URL : amqp://127.0.0.1:5672/"
    
    2. Access RabbitMQ using using the obtained URL.
    
    To Access the RabbitMQ Management interface:
    
    1. Get the RabbitMQ Management URL and associate its hostname to your cluster external IP:
    
       export CLUSTER_IP=$(minikube ip) # On Minikube. Use: `kubectl cluster-info` on others K8s clusters
       echo "RabbitMQ Management: http://rabbitmq.evescn.com/"
       echo "$CLUSTER_IP  rabbitmq.evescn.com" | sudo tee -a /etc/hosts
    
    2. Open a browser and acchelm uninstall rabbitmq
    

    6. 验证 rabbitmq 集群

    • 查看 pod
    $ helm -n test-middleware list
    NAME            	NAMESPACE      	REVISION	UPDATED                                	STATUS  	CHART         	APP VERSION
    rabbitmq-cluster	test-middleware	1       	2022-05-14 22:37:15.184660083 -0400 EDT	deployed	rabbitmq-9.0.8	3.9.17
    
    
    $ kubectl -n test-middleware get pods -l app.kubernetes.io/name=rabbitmq
    NAME                 READY   STATUS    RESTARTS   AGE
    rabbitmq-cluster-0   1/1     Running   0          6m22s
    rabbitmq-cluster-1   1/1     Running   0          5m12s
    rabbitmq-cluster-2   1/1     Running   0          3m40s
    
    • 查看 pvc
    $ kubectl -n test-middleware get pvc
    NAME                                STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS           AGE
    data-rabbitmq-cluster-0             Bound    pvc-d6c5392f-889c-47e9-80cc-168d2408b8fa   10Gi       RWO            openebs-jiva-default   6m43s
    data-rabbitmq-cluster-1             Bound    pvc-051edb44-af96-465b-b325-f829b10d195a   10Gi       RWO            openebs-jiva-default   5m33s
    data-rabbitmq-cluster-2             Bound    pvc-04905017-80ae-4ec8-87c9-2aee18d00fe8   10Gi       RWO            openebs-jiva-default   4m1s
    
    • 登陆 web 页面查看

    http://rabbitmq.evescn.com/

    • 获取登陆 web 的账号密码
    $ echo "Username      : admin"
    Username      : admin
    
    $ echo "Password      : $(kubectl get secret --namespace test-middleware rabbitmq-cluster -o jsonpath="{.data.rabbitmq-password}" | base64 --decode)"
    
    Password      : admin123
    

    参考文档

    https://artifacthub.io/packages/helm/bitnami/rabbitmq
    
  • 相关阅读:
    个人中心标签页导航(2017.12.13)
    评论列表显示及排序,个人中心显示(2017.12.12)
    20199329 2019-2020-2 《网络攻防实践》 综合实践
    20199329 2019-2020-2 《网络攻防实践》第十二周作业
    20199329 2019-2020-2 《网络攻防实践》第十一周作业
    20199329 2019-2020-2 《网络攻防实践》第十周作业
    20199329 2019-2020-2 《网络攻防实践》第九周作业
    20199329 2019-2020-2 《网络攻防实践》第八周作业
    20199329 2019-2020-2 《网络攻防实践》第七周作业
    20199329 2019-2020-2 《网络攻防实践》第六周作业
  • 原文地址:https://www.cnblogs.com/evescn/p/16274045.html
Copyright © 2020-2023  润新知