<p>I'm starting in kubernetes and I'm having some issues reaching out my <code>rabbitmq</code> service inside a <code>messaging</code> namespace from my <code>banking</code> service inside the <code>backend</code> namespace. I know it's supposed to be "easy" by reading the documentation: <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/</a></p>

<p>However, I've spent more than a day trying to figure out why I'm not able to connect to the rabbitmq client host</p>

<p>These are my yaml files:</p>

<p>banking-ip-service:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: banking-ip-service
  namespace: backend
spec:
  type: NodePort
  ports:
    - port: 8000
      targetPort: 8000
      nodePort: 30080
      protocol: TCP
      name: "banking-api"
  selector:
    component: bank</code></pre>
</div>
</div>
</p>

<p>banking deployment:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: banking
  namespace: backend
spec:
  replicas: 1
  selector:
    matchLabels:
      component: bank
  template:
    metadata:
      labels:
        component: bank
    spec:
      containers:
        - name: banking
          image: user/myownimage
          env:
            - name: URL
              # cluster ip
              value: rabbit-ip-service.messaging.svc.cluster.local
            - name: PORT
              value: "5672"
            - name: USER
              value: "guest"
            - name: PASSWORD
              value: "guest"
          ports:
            - containerPort: 8000
          resources:
            requests:
              memory: "64Mi"
              cpu: "25m"
            limits:
              memory: "128Mi"
              cpu: "50m"
      restartPolicy: Always
      imagePullSecrets:
        - name: regcred</code></pre>
</div>
</div>
</p>

<p>rabbitmq-ip-service:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: rabbit-ip-service
  namespace: messaging
spec:
 type: ClusterIP
 ports:
    - port: 5672
      targetPort: 5672
      name: "rabbit-api"
    - port: 15672
      targetPort: 15672
      name: "rabbit-manager"
 selector:
  component: rabbitmq</code></pre>
</div>
</div>
</p>

<p>rabbitmq deployment:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
  name: rabbitmq
  labels:
    component: rabbitmq
  namespace: messaging
spec:
  containers:
  - image: rabbitmq:3.5.4-management
    name: rabbitmq
    ports:
      - containerPort: 5672
        name: service
      - containerPort: 15672
        name: management
    resources:
      requests:
        memory: "64Mi"
        cpu: "50m"
      limits:
        memory: "128Mi"
        cpu: "100m"
    volumeMounts:
    - name: config-volume
      mountPath: /etc/rabbitmq
  volumes:
  - name: config-volume
    configMap:
      name: rabbitmq-config
      items:
      - key: rabbitmq.conf
        path: rabbitmq.conf
      - key: enabled_plugins
        path: enabled_plugins</code></pre>
</div>
</div>
</p>

<p>This is the output when running <code>kubectl describe svc rabbit-ip-service -n messaging</code> :</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>Name:              rabbit-ip-service
Namespace:         messaging
Labels:            &lt;none&gt;
Annotations:       kubectl.kubernetes.io/last-applied-configuration:
                     {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"rabbit-ip-service","namespace":"messaging"},"spec":{"ports":[{"na...
Selector:          component=rabbitmq
Type:              ClusterIP
IP:                10.106.248.55
Port:              rabbit-api  5672/TCP
TargetPort:        5672/TCP
Endpoints:         172.17.0.5:5672
Port:              rabbit-manager  15672/TCP
TargetPort:        15672/TCP
Endpoints:         172.17.0.5:15672
Session Affinity:  None
Events:            &lt;none&gt;</code></pre>
</div>
</div>
</p>

<p>If I hardcode the url value inside the <code>backend</code> deployment it doesn't work either:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>env:
  - name: URL
    # cluster ip
    value: 10.106.248.55:5672</code></pre>
</div>
</div>
</p>

alex
<p>I made it work by just removing the volumes temporarily that were using the configmaps:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
  name: rabbitmq
  labels:
    component: rabbitmq
  namespace: messaging
spec:
  containers:
  - image: rabbitmq:3.5.4-management
    name: rabbitmq
    ports:
      - containerPort: 5672
        name: service
      - containerPort: 15672
        name: management
    resources:
      requests:
        memory: "64Mi"
        cpu: "50m"
      limits:
        memory: "128Mi"
        cpu: "100m"</code></pre>
</div>
</div>
</p>
