1 kind: Deployment 2 apiVersion: apps/v1 3 metadata: 4 name: rabbitmq-deployment 5 spec: 6 replicas: 1 7 selector: 8 matchLabels: 9 app: rabbitmq10 template: 11 metadata: 12 creationTimestamp: null 13 labels: 14 app: rabbitmq15 spec: 16 volumes: 17 - name: host-time 18 hostPath: 19 path: /etc/localtime 20 type: '' 21 containers: 22 - name: rabbitmq 23 image: rabbitmq 24 ports: 25 - containerPort: 5672 26 protocol: TCP 27 - containerPort: 15672 28 protocol: TCP 29 resources: {} 30 volumeMounts: 31 - name: host-time 32 readOnly: true 33 mountPath: /etc/localtime 34 lifecycle: 35 postStart: 36 exec: 37 command: 38 - /bin/bash 39 - '-c' 40 - >- 41 echo management_agent.disable_metrics_collector = false > 42 /etc/rabbitmq/conf.d/management_agent.disable_metrics_collector.conf 43 && rabbitmq-plugins enable rabbitmq_management
1 docker exec -it {rabbitmq容器名称或者id} rabbitmq-plugins enable rabbitmq_management 2 3 #重启rabbitmq容器 4 docker retart {rabbitmq容器id}
2.无法进入管理员操作界面
#进入rabbitmq容器 docker exec -it {rabbitmq容器名称或者id} /bin/bash #进入容器后,cd到以下路径 cd /etc/rabbitmq/conf.d/ #修改 management_agent.disable_metrics_collector = false echo management_agent.disable_metrics_collector = false > management_agent.disable_metrics_collector.conf #退出容器 exit #重启rabbitmq容器 docker retart {rabbitmq容器id}
上述2个问题可以在Deployment中通过容器启动后命令完成
1 lifecycle: 2 postStart: 3 exec: 4 command: 5 - /bin/bash 6 - '-c' 7 - >- 8 echo management_agent.disable_metrics_collector = false > 9 /etc/rabbitmq/conf.d/management_agent.disable_metrics_collector.conf 10 && rabbitmq-plugins enable rabbitmq_management