mongodb / mongodb-kubernetes-operator

MongoDB Community Kubernetes Operator
Other
1.23k stars 501 forks source link

replicaSetHorizons not working with external access #1319

Closed eBeyond closed 11 months ago

eBeyond commented 1 year ago

What did you do to encounter the bug? I've created a ReplicaSet with the configured horizons:

kind: MongoDBCommunity
metadata:
  name: mongodb
  namespace: mongodb
spec:
  members: 3
  type: ReplicaSet
  # version: "5.0.5"
  version: "6.0.5"
  replicaSetHorizons:
  - horizon: mongodb-0.<external-domain>:31181
  - horizon: mongodb-1.<external-domain>:31182
  - horizon: mongodb-2.<external-domain>:31183

but when trying to connect with mongo compass it took some time to timeout and I got: getaddrinfo EAI_AGAIN mongodb-0.mongodb-svc.mongodb.svc.<cluster-domain>

I've tried it with several other ways to configure horizons:

  - mongodb-0: mongodb-0.<external-domain>:31181
  - mongodb-1: mongodb-1.<external-domain>:31182
  - mongodb-2: mongodb-2.<external-domain>:31183

,

  - horizon1: mongodb-0.<external-domain>:31181
  - horizon2: mongodb-1.<external-domain>:31182
  - horizon3: mongodb-2.<external-domain>:31183

,

  - horizon1: mongodb-0.<external-domain>:31181
    horizon2: mongodb-1.<external-domain>:31182
    horizon3: mongodb-2.<external-domain>:31183
  - horizon1: mongodb-0.<external-domain>:31181
    horizon2: mongodb-1.<external-domain>:31182
    horizon3: mongodb-2.<external-domain>:31183
  - horizon1: mongodb-0.<external-domain>:31181
    horizon2: mongodb-1.<external-domain>:31182
    horizon3: mongodb-2.<external-domain>:31183

or

  - external: "mongodb-0.<external-domain>:31181" 
    internal: "mongodb-0.mongodb-svc.mongodb.svc.<cluster-domain>:31181"
  - external: "mongodb-1.<external-domain>:31182"
    internal: "mongodb-1.mongodb-svc.mongodb.svc.<cluster-domain>:31182"
  - external: "mongodb-2.<external-domain>:31183" 
    internal: "mongodb-2.mongodb-svc.mongodb.svc.<cluster-domain>:31183"

Within to code horizons should be a map[string]string. As such I understand, that the value of the map is the domain. But what should be the first one? Or more generally: What should be the key in the replicaSetHorizons? As of now I've got no idea of fixing it. (As of testing I've disabled TLS to avoid any issues with that and concentrate on the horizons)

By the way: Most of the examples above I've found in the issues in this project which are mentioned as valid. As such I'm confused... :)

Thanks Marc

rdxmb commented 1 year ago
spec:
  members: 3
  type: ReplicaSet
  version: "5.0.5"
  replicaSetHorizons:
    - horizon: mongodb-0.DOMAIN.com:27017
    - horizon: mongodb-1.DOMAIN.com:27017
    - horizon: mongodb-2.DOMAIN.com:27017
  security:
    tls:
      enabled: true
      caConfigMapRef:
        name: mongodb-ca.crt
      certificateKeySecretRef:
        name: mongodb-tls.crt
    authentication:
      modes: ["SCRAM"]

works in my case. However, I am moving from this project, so I cannot give any further help.

github-actions[bot] commented 1 year ago

This issue is being marked stale because it has been open for 60 days with no activity. Please comment if this issue is still affecting you. If there is no change, this issue will be closed in 30 days.

github-actions[bot] commented 11 months ago

This issue was closed because it became stale and did not receive further updates. If the issue is still affecting you, please re-open it, or file a fresh Issue with updated information.

sagarshrestha24 commented 5 months ago

Hello Team I got same error while accessing from connection string

Connecting to:      mongodb://<credentials>@mongodb-0.example.com:27017,mongodb-1.example.com:27017/admin?authMechanism=DEFAULT&appName=mongosh+2.1.5
MongoServerSelectionError: getaddrinfo EAI_AGAIN mongodb-replica-set-0.mongodb-replica-set-svc.default.svc.cluster.local

here is my configuration file of mongo

apiVersion: mongodbcommunity.mongodb.com/v1 
kind: MongoDBCommunity 
metadata: 
  name: mongodb-replica-set 
spec: 
  members: 2
  replicaSetHorizons:
  - external: "mongodb-0.example.com:27017"
    internal: "mongodb-replica-set-0.mongodb-replica-set-svc.default.svc.cluster.local:27017"
  - external: "mongodb-1.example.com:27018"
    internal: "mongodb-replica-set-1.mongodb-replica-set-svc.default.svc.cluster.local:27017"
  type: ReplicaSet 
  version: "5.0.5" 
  security:
    authentication: 
      modes: ["SCRAM"]
  additionalMongodConfig:
    storage.wiredTiger.engineConfig.journalCompressor: zlib
  statefulSet:
    spec:
      template:
        spec: 
          hostAliases:
          - ip: "172.18.255.203"
            hostnames:
            - "mongodb-0.example.com"
          - ip: "172.18.255.203"
            hostnames:
            - "mongodb-1.example.com"
  users: 
    - name: admin 
      db: admin 
      passwordSecretRef: # a reference to the secret that will be used to generate the user's password 
        name: admin-password 
      roles: 
        - name: clusterAdmin 
          db: admin 
        - name: userAdminAnyDatabase 
          db: admin 
        - name: root 
          db: admin 
      scramCredentialsSecretName: admin-scram