Question about services

Hi all,

I am new to kubernetes and I have a problem with connecting to rabbitmq running in my kubernetes cluster (v1.22.1).

I installed rabbitmq using helm:

helm install rabbitmq --set persistence.accessMode=ReadWriteMany --set persistence.storageClass=nfs-client --set persistence.size=10Gi --namespace rabbitmq bitnami/rabbitmq

Output after installation:

To Access the RabbitMQ AMQP port:
echo "URL : amqp://127.0.0.1:5672/"
kubectl port-forward --namespace rabbitmq svc/rabbitmq 5672:5672

To Access the RabbitMQ Management interface:
echo "URL : http://127.0.0.1:15672/"
kubectl port-forward --namespace rabbitmq svc/rabbitmq 15672:15672

How can I ensure that I can access rabbitmq management webinterface from my own network.
At this moment I have 2 services:

$ kubectl describe services rabbitmq -n rabbitmq
Name:              rabbitmq
Namespace:         rabbitmq
Labels:            app.kubernetes.io/instance=rabbitmq
                   app.kubernetes.io/managed-by=Helm
                   app.kubernetes.io/name=rabbitmq
                   helm.sh/chart=rabbitmq-8.29.1
Annotations:       meta.helm.sh/release-name: rabbitmq
                   meta.helm.sh/release-namespace: rabbitmq
Selector:          app.kubernetes.io/instance=rabbitmq,app.kubernetes.io/name=rabbitmq
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                10.101.99.4
IPs:               10.101.99.4
Port:              amqp  5672/TCP
TargetPort:        amqp/TCP
Endpoints:         192.168.1.133:5672
Port:              epmd  4369/TCP
TargetPort:        epmd/TCP
Endpoints:         192.168.1.133:4369
Port:              dist  25672/TCP
TargetPort:        dist/TCP
Endpoints:         192.168.1.133:25672
Port:              http-stats  15672/TCP
TargetPort:        stats/TCP
Endpoints:         192.168.1.133:15672
Session Affinity:  None
Events:            <none>
kubectl describe services rabbitmq-headless -n rabbitmq
Name:              rabbitmq-headless
Namespace:         rabbitmq
Labels:            app.kubernetes.io/instance=rabbitmq
                   app.kubernetes.io/managed-by=Helm
                   app.kubernetes.io/name=rabbitmq
                   helm.sh/chart=rabbitmq-8.29.1
Annotations:       meta.helm.sh/release-name: rabbitmq
                   meta.helm.sh/release-namespace: rabbitmq
Selector:          app.kubernetes.io/instance=rabbitmq,app.kubernetes.io/name=rabbitmq
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                None
IPs:               None
Port:              epmd  4369/TCP
TargetPort:        epmd/TCP
Endpoints:         192.168.1.133:4369
Port:              amqp  5672/TCP
TargetPort:        amqp/TCP
Endpoints:         192.168.1.133:5672
Port:              dist  25672/TCP
TargetPort:        dist/TCP
Endpoints:         192.168.1.133:25672
Port:              http-stats  15672/TCP
TargetPort:        stats/TCP
Endpoints:         192.168.1.133:15672
Session Affinity:  None
Events:            <none>

Do I have to create a new service using type: NodePort ? I already tried the following

kind: Service
apiVersion: v1
metadata:
  name: rabbitmq-ext
  labels:
    app: rabbitmq
    type: LoadBalancer
spec:
  type: NodePort
  ports:
   - name: http
     protocol: TCP
     port: 15672
     targetPort: 15672
     nodePort: 31673
   - name: amqp
     protocol: TCP
     port: 5672
     targetPort: 5672
     nodePort: 30673
  selector:
    app: rabbitmq

Running netstat on the node I see the ports 31673 and 30673. But I can’t connect.

Pod is running:

kubectl get pods -n rabbitmq
NAME         READY   STATUS    RESTARTS   AGE
rabbitmq-0   1/1     Running   0          94m

Name:         rabbitmq-0
Namespace:    rabbitmq
Priority:     0
Node:         lepkub1s5/10.73.5.147
Start Time:   Wed, 23 Feb 2022 20:15:50 +0100
Labels:       app.kubernetes.io/instance=rabbitmq
              app.kubernetes.io/managed-by=Helm
              app.kubernetes.io/name=rabbitmq
              controller-revision-hash=rabbitmq-774768c886
              helm.sh/chart=rabbitmq-8.29.1
              statefulset.kubernetes.io/pod-name=rabbitmq-0
Annotations:  checksum/config: 31bd007aae3596b483b5877a6c0006c60201366c7e250a6f09b69c9cc7193c58
              checksum/secret: 6b8cdff02859c15e9fba5c24a2cbb8ffcc2b32e6eed6436b5e5348474ba78935
              cni.projectcalico.org/containerID: 7a2dd41f2fbfc778355da08ad73cb759d50d5f6296c996dfea08c2fe5bc24bb2
              cni.projectcalico.org/podIP: 192.168.1.133/32
              cni.projectcalico.org/podIPs: 192.168.1.133/32
Status:       Running
IP:           192.168.1.133
IPs:
  IP:           192.168.1.133
Controlled By:  StatefulSet/rabbitmq
Containers:
  rabbitmq:
    Container ID:   containerd://279b6ace47d95ee6658ce276c51ed7de6d0ae40b4f39d83c05a889e8478b0009
    Image:          docker.io/bitnami/rabbitmq:3.9.13-debian-10-r31
    Image ID:       docker.io/bitnami/rabbitmq@sha256:a825f55a837eca0329a7510eb67b0774b5f0c41b909131756ffc920781683a1c
    Ports:          5672/TCP, 25672/TCP, 15672/TCP, 4369/TCP
    Host Ports:     0/TCP, 0/TCP, 0/TCP, 0/TCP
    State:          Running
      Started:      Wed, 23 Feb 2022 20:16:08 +0100
    Ready:          True
    Restart Count:  0
    Liveness:       exec [/bin/bash -ec rabbitmq-diagnostics -q ping] delay=120s timeout=20s period=30s #success=1 #failure=6
    Readiness:      exec [/bin/bash -ec rabbitmq-diagnostics -q check_running && rabbitmq-diagnostics -q check_local_alarms] delay=10s timeout=20s period=30s #success=1 #failure=3
    Environment:
      BITNAMI_DEBUG:              false
      MY_POD_IP:                   (v1:status.podIP)
      MY_POD_NAME:                rabbitmq-0 (v1:metadata.name)
      MY_POD_NAMESPACE:           rabbitmq (v1:metadata.namespace)
      K8S_SERVICE_NAME:           rabbitmq-headless
      K8S_ADDRESS_TYPE:           hostname
      RABBITMQ_FORCE_BOOT:        no
      RABBITMQ_NODE_NAME:         rabbit@$(MY_POD_NAME).$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE).svc.cluster.local
      K8S_HOSTNAME_SUFFIX:        .$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE).svc.cluster.local
      RABBITMQ_MNESIA_DIR:        /bitnami/rabbitmq/mnesia/$(RABBITMQ_NODE_NAME)
      RABBITMQ_LDAP_ENABLE:       no
      RABBITMQ_LOGS:              -
      RABBITMQ_ULIMIT_NOFILES:    65536
      RABBITMQ_USE_LONGNAME:      true
      RABBITMQ_ERL_COOKIE:        <set to the key 'rabbitmq-erlang-cookie' in secret 'rabbitmq'>  Optional: false
      RABBITMQ_LOAD_DEFINITIONS:  no
      RABBITMQ_SECURE_PASSWORD:   yes
      RABBITMQ_USERNAME:          user
      RABBITMQ_PASSWORD:          <set to the key 'rabbitmq-password' in secret 'rabbitmq'>  Optional: false
      RABBITMQ_PLUGINS:           rabbitmq_management, rabbitmq_peer_discovery_k8s, rabbitmq_auth_backend_ldap
    Mounts:
      /bitnami/rabbitmq/conf from configuration (rw)
      /bitnami/rabbitmq/mnesia from data (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-fbb5n (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  data:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  data-rabbitmq-0
    ReadOnly:   false
  configuration:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      rabbitmq-config
    Optional:  false
  kube-api-access-fbb5n:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:                      <none>

Can someone help me ?
Thanks in advance .

Is that problem solved now? I experience the same.