无法使用复制控制器和服务在端口15672上访问rabbit mq

时间:2017-11-11 06:34:04

标签: rabbitmq kubernetes

这是我的ReplicationController

apiVersion: v1 
kind: ReplicationController
metadata:
  name: rmq-rc1234
spec:
  selector:
    app: rmq
  replicas: 1 
  template: 
    metadata:    
      labels:
        app: rmq
    spec:
      containers:
      - name: rmq
        image: rabbitmq
        env:
        - name: RABBITMQ_DEFAULT_USER
          value: "rabbitmq"
        - name: RABBITMQ_DEFAULT_PASS
          value: "rabbitmq"
        ports: 
        - containerPort: 5672
        - containerPort: 15672

下面是我的Service文件:

apiVersion: v1
kind: Service
metadata:
  name: rmq-svc
  labels:
    app: rmq
spec:
  type: NodePort 
  ports:
  - port: 15672
    name: port-mgmt
    nodePort: 30006
    protocol: TCP
  - port: 5672
    name: port-actual
    nodePort: 30007
    protocol: TCP
  selector:
    app: rmq

kubebctl get pods的结果是:

rmq-rc1234-msdbf     1/1       Running   0          9h

kubectl logs的输出是:

=INFO REPORT==== 10-Nov-2017::21:17:43 ===
Waiting for Mnesia tables for 30000 ms, 9 retries left

=INFO REPORT==== 10-Nov-2017::21:17:43 ===
Waiting for Mnesia tables for 30000 ms, 9 retries left

=INFO REPORT==== 10-Nov-2017::21:17:43 ===
Waiting for Mnesia tables for 30000 ms, 9 retries left

=INFO REPORT==== 10-Nov-2017::21:17:43 ===
Priority queues enabled, real BQ is rabbit_variable_queue

=INFO REPORT==== 10-Nov-2017::21:17:43 ===
Starting rabbit_node_monitor

=INFO REPORT==== 10-Nov-2017::21:17:43 ===
Adding vhost '/'

=INFO REPORT==== 10-Nov-2017::21:17:43 ===
Creating user 'rabbitmq'

=INFO REPORT==== 10-Nov-2017::21:17:43 ===
Setting user tags for user 'rabbitmq' to [administrator]

=INFO REPORT==== 10-Nov-2017::21:17:43 ===
Setting permissions for 'rabbitmq' in '/' to '.*', '.*', '.*'

=INFO REPORT==== 10-Nov-2017::21:17:43 ===
msg_store_transient: using rabbit_msg_store_ets_index to provide index

=INFO REPORT==== 10-Nov-2017::21:17:43 ===
msg_store_persistent: using rabbit_msg_store_ets_index to provide index

=WARNING REPORT==== 10-Nov-2017::21:17:43 ===
msg_store_persistent: rebuilding indices from scratch

=INFO REPORT==== 10-Nov-2017::21:17:44 ===
started TCP Listener on [::]:5672
 completed with 0 plugins.

=INFO REPORT==== 10-Nov-2017::21:17:44 ===
Server startup complete; 0 plugins started.

=INFO REPORT==== 10-Nov-2017::21:18:07 ===
accepting AMQP connection <0.374.0> (10.44.0.0:51450 -> 10.44.0.13:5672)

=ERROR REPORT==== 10-Nov-2017::21:18:07 ===
closing AMQP connection <0.374.0> (10.44.0.0:51450 -> 10.44.0.13:5672):
{bad_header,<<"GET / HT">>}

我无法通过网络浏览器获得端口15672的任何响应。但是我从端口5672得到了一些回应,日志也确认了相同。

有人可以帮我用网络浏览器访问RabbitMQ吗?

1 个答案:

答案 0 :(得分:1)

您使用未安装管理插件的图片rabbitmq创建了RabbitMQ pod。

要获得对RabbitMQ的WEB访问权限,您需要使用rabbitmq:3-management图片:

apiVersion: v1 
kind: ReplicationController
metadata:
  name: rmq-rc1234
spec:
  selector:
    app: rmq
  replicas: 1 
  template: 
    metadata:    
      labels:
        app: rmq
    spec:
      containers:
      - name: rmq
        image: rabbitmq:3-management
        env:
        - name: RABBITMQ_DEFAULT_USER
          value: "rabbitmq"
        - name: RABBITMQ_DEFAULT_PASS
          value: "rabbitmq"
        ports: 
        - containerPort: 5672
        - containerPort: 15672