Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't communicate with replicaset using external access #29650

Open
igolka97 opened this issue Sep 28, 2024 · 1 comment
Open

Can't communicate with replicaset using external access #29650

igolka97 opened this issue Sep 28, 2024 · 1 comment
Assignees
Labels
mongodb tech-issues The user has a technical issue about an application triage Triage is needed

Comments

@igolka97
Copy link

igolka97 commented Sep 28, 2024

Name and Version

bitnami/mongodb 15.6.26

What architecture are you using?

amd64

What steps will reproduce the bug?

  1. deploy regular bitnami/mongodb helm chart
  2. try to connect to replicaset externally using MongoDB Compass client without directConnection=true

Are you using any custom parameters or values?

architecture: replicaset
replicaCount: 2
externalAccess:
  enabled: true
  service:
    type: NodePort
    port: 27017
    nodePorts:
      - 30001
      - 30002
    publicNames:
      - sub.domain.com
      - sub.domain.com
    domain: "sub.domain.com"
    externalTrafficPolicy: Cluster

What is the expected behavior?

I can connect to cluster without any issues

What do you see instead?

getting error connect ENETUNREACH 192.168.0.7:30001

Additional information

Closed issue: #13485

I found out that replicaset initialised with names like 192.168.0.7:30001 (where 192.168.0.7 is my internal host ip and 30001 is nodePort). It possible to connect externally with directConnection=true setting FQDN or ip only once. In case of that, when you try to connect to cluster without directConnection your external client trying to connect to all replicas in set at once right after connection init and fails, as of 192.168.0.7 ip available only in cluster network. I guess that MONGODB_ADVERTISED_HOSTNAME and following lines is a culprit:

{{- if and .Values.replicaSetHostnames (not .Values.externalAccess.enabled) }}
- name: MONGODB_ADVERTISED_HOSTNAME
value: "$(MY_POD_NAME).$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE).svc.{{ .Values.clusterDomain }}"
{{- end }}

values:

architecture: replicaset
replicaCount: 2
externalAccess:
  enabled: true
  service:
    type: NodePort
    port: 27017
    nodePorts:
      - 30001
      - 30002
    publicNames:
      - sub.domain.com
      - sub.domain.com
    domain: "sub.domain.com"
    externalTrafficPolicy: Cluster
members: [
    {
      _id: 0,
      name: '192.168.0.7:30001',
      health: 1,
      state: 1,
      stateStr: 'PRIMARY',
      uptime: 586,
      optime: [Object],
      optimeDate: 2024-09-28T22:21:37.000Z,
      lastAppliedWallTime: 2024-09-28T22:21:37.619Z,
      lastDurableWallTime: 2024-09-28T22:21:37.619Z,
      syncSourceHost: '',
      syncSourceId: -1,
      infoMessage: '',
      electionTime: Timestamp({ t: 1727561547, i: 1 }),
      electionDate: 2024-09-28T22:12:27.000Z,
      configVersion: 4,
      configTerm: 8,
      self: true,
      lastHeartbeatMessage: ''
    },
    {
      _id: 1,
      name: '192.168.0.6:30002',
      health: 1,
      state: 2,
      stateStr: 'SECONDARY',
      uptime: 562,
      optime: [Object],
      optimeDurable: [Object],
      optimeDate: 2024-09-28T22:21:37.000Z,
      optimeDurableDate: 2024-09-28T22:21:37.000Z,
      lastAppliedWallTime: 2024-09-28T22:21:37.619Z,
      lastDurableWallTime: 2024-09-28T22:21:37.619Z,
      lastHeartbeat: 2024-09-28T22:21:39.875Z,
      lastHeartbeatRecv: 2024-09-28T22:21:40.286Z,
      pingMs: Long('0'),
      lastHeartbeatMessage: '',
      syncSourceHost: '192.168.0.7:30001',
      syncSourceId: 0,
      infoMessage: '',
      configVersion: 4,
      configTerm: 8
    }
  ],```
@igolka97 igolka97 added the tech-issues The user has a technical issue about an application label Sep 28, 2024
@github-actions github-actions bot added the triage Triage is needed label Sep 28, 2024
@carrodher
Copy link
Member

Thank you for bringing this issue to our attention. We appreciate your involvement! If you're interested in contributing a solution, we welcome you to create a pull request. The Bitnami team is excited to review your submission and offer feedback. You can find the contributing guidelines here.

Your contribution will greatly benefit the community. Feel free to reach out if you have any questions or need assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mongodb tech-issues The user has a technical issue about an application triage Triage is needed
Projects
None yet
Development

No branches or pull requests

2 participants