<p>kubernetes cluster is running on two nodes. one master , one worker ... 
weave net is pod network. </p>

<pre><code>[root@irf-centos1 ~]# kubectl cluster-info
Kubernetes master is running at https://10.8.156.184:6443
KubeDNS is running at https://10.8.156.184:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
</code></pre>

<p>have deployed the rabbit docker image as container in kubernetes pod. </p>

<pre><code>[root@irf-centos1 ~]# kubectl get pods
NAME                        READY   STATUS    RESTARTS   AGE
rabbitmq-86bd97fd9d-8h444   1/1     Running   0          51m
rabbitmq-86bd97fd9d-n2kgk   1/1     Running   0          51m
</code></pre>

<p>following are the service and deployment yaml file </p>

<p><strong>deployment file</strong> </p>

<pre><code>---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: rabbitmq
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: rabbitmqapp
    spec:
      containers:
        -
          image: "docker.io/rabbitmq:latest"
          imagePullPolicy: Always
          name: rabbitmq
          ports:
            -
              containerPort: 5672
              name: http-port
          volumeMounts:
            -
              mountPath: /var/rabbitmqapp_home
              name: rabbitmqapp-home
      volumes:
        -
          emptyDir: {}
          name: rabbitmqapp-home
</code></pre>

<p><strong>service file</strong> </p>

<pre><code>---
apiVersion: v1
kind: Service
metadata:
  name: rabbitmq
  namespace: default
spec:
  ports:
    -
      port: 5672
      targetPort: 5672
      protocol: TCP
      nodePort: 31111
  selector:
    app: rabbitmqapp
  type: NodePort
</code></pre>

<p>here are the services and deployment details </p>

<pre><code>[root@irf-centos1 ~]# kubectl get deployments
NAME       READY   UP-TO-DATE   AVAILABLE   AGE
rabbitmq   2/2     2            2           55m


[root@irf-centos1 ~]# kubectl get services
NAME         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
kubernetes   ClusterIP   10.96.0.1      &lt;none&gt;        443/TCP          3d
rabbitmq     NodePort    10.98.204.64   &lt;none&gt;        5672:31111/TCP   55m
</code></pre>

<p>now, when i am trying to hit the rabbitmq dashboard/UI on the node port. it is not accessible </p>

<pre><code>[root@irf-centos1 ~]# curl http://10.8.156.187:31111
curl: (56) Recv failure: Connection reset by peer
AMQP    [root@irf-centos1 ~]#
</code></pre>

<p>when i hit the same URL from the web browser, nothing is happening </p>

<p>please suggest </p>

<p>NOTE: this cluster is deployed using kubeadm on AZure VMs. for troubleshooting purpose, i have opened all inbound/outbound ports on these VMs so that , it should not be a firewall , port blocking issue. </p>

<p><strong>Edit 1:</strong> </p>

<p>I modified the service file as follows and redeployed the same. PSB</p>

<pre><code>---
apiVersion: v1
kind: Service
metadata:
  name: rabbitmq
  namespace: default
spec:
  ports:
    - name: ui
      protocol: TCP
      port: 15672
      targetPort: 15672
      nodePort: 31112
    - name: service
      port: 5672
      targetPort: 5672
      protocol: TCP
      nodePort: 31111
  selector:
    app: rabbitmq
  type: NodePort
</code></pre>

<p>still getting the same error </p>

<pre><code>[root@irf-centos1 ~]# curl -I http://guest:guest@10.8.156.187:31111/api/users
curl: (56) Recv failure: Connection reset by peer
AMQP    [root@irf-centos1 ~]# curl -I http://guest:guest@10.8.156.187:31112/api/users
curl: (7) Failed connect to 10.8.156.187:31112; Connection refused
</code></pre>

<p>For rabbitmq dashboard/UI, it's running on : <code>15672</code></p>

<p>So port number in service file should be included : <code>15672</code> </p>

<p>Then access to dashboard/UI create user for application. then <code>curl</code> using this user.</p>

<pre><code>---
apiVersion: v1
kind: Service
metadata:
  name: rabbitmq
  namespace: default
spec:
  ports:
    -
      port: 5672
      targetPort: 5672
      protocol: TCP
      nodePort: 31111
    - 
      protocol: TCP
      port: 15672
      targetPort: 15672
      nodePort: 31112

  selector:
    app: rabbitmqapp
  type: NodePort
</code></pre>

<p>Or using default username &amp; password <code>guest</code> of rabitmq:</p>

<pre><code>curl -I http://guest:guest@10.8.156.187:31112/api/users
</code></pre>

<p>Deployment file add containerPort: </p>

<pre><code>      image: "docker.io/rabbitmq:latest"
      imagePullPolicy: Always
      name: rabbitmq
      ports:
        -
          containerPort: 5672
          name: http-port
          containerPort: 15672
          name: ui-port
</code></pre>
