Uploaded image for project: 'Percona Operator for MongoDB'
  1. Percona Operator for MongoDB
  2. K8SPSMDB-929

Can't connect to MongoDB Replica Set via LoadBalancer

Details

    • Bug
    • Status: Done
    • Medium
    • Resolution: Fixed
    • 1.14.0
    • 1.15.0
    • None
    • None
    • Yes
    • Yes
    • Yes

    Description

      In 1.14.0 of the operator we changed the way how we configure replica set - now it relies on cluster FQDNs: https://jira.percona.com/browse/K8SPSMDB-867

      It is a good move and something that Mongo recommends.

       

      The problem

      This change created a problem, that if I expose a single replica set through a LoadBalancer, I can't connect to it anymore getting the following error:

       $ mongosh 'mongodb://databaseAdmin:[email protected]:27017,35.226.148.87:27017,35.232.216.202:27017/?replicaSet=rs0&authSource=admin&tls=false'
      Current Mongosh Log ID: 6464cc5ae2927bbfc24e542d
      Connecting to:          mongodb://<credentials>@35.202.76.124:27017,35.226.148.87:27017,35.232.216.202:27017/?replicaSet=rs0&authSource=admin&tls=false&appName=mongosh+1.8.2
      MongoNetworkError: getaddrinfo ENOTFOUND my-cluster-name-rs0-1.my-cluster-name-rs0.test.svc.cluster.local 

       

      This is understandable, as the replica set and mongo does not know anything about load balancer public IP-addresses.

      At the same time it is still possible to connect to the database through a single IP:

       $ mongosh 'mongodb://databaseAdmin:[email protected]:27017/?authSource=admin&tls=false'
      Current Mongosh Log ID: 6464cd3ba20966b7677007a2
      Connecting to:          mongodb://<credentials>@35.226.148.87:27017/?authSource=admin&tls=false&directConnection=true&appName=mongosh+1.8.2
      Using MongoDB:          6.0.4-3
      Using Mongosh:          1.8.2

       

      Workaround

      The user can go back to old behavior via clusterServiceDNSMode if needed.

       

      For the future, we might need to look into SplitHorizon.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sergey.pronin Sergey Pronin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Smart Checklist