Mongo ping: server selection error: server selection timeout

I use k8s version 1.25

my mongodb cr.yaml

apiVersion: psmdb.percona.com/v1
kind: PerconaServerMongoDB
metadata:
  name: mongodb
  finalizers:
    - delete-psmdb-pods-in-order
spec:
  crVersion: 1.14.0
  image: percona/percona-server-mongodb:5.0.11-10
  imagePullPolicy: Always
  allowUnsafeConfigurations: false
  updateStrategy: SmartUpdate
  upgradeOptions:
    versionServiceEndpoint: https://check.percona.com
    apply: 5.0-recommended
    schedule: "0 2 * * *"

  secrets:
    users: mongodb-secret
    encryptionKey: mongodb-mongodb-encryption-key

  pmm:
    enabled: false
    image: percona/pmm-client:2.30.0
    serverHost: monitoring-service

  replsets:
    - name: rs0
      size: 3
      affinity:
        antiAffinityTopologyKey: "kubernetes.io/hostname"
      podDisruptionBudget:
        maxUnavailable: 1
      expose:
        enabled: false
        exposeType: ClusterIP
      resources:
        limits:
          cpu: "300m"
          memory: "0.5G"
        requests:
          cpu: "300m"
          memory: "0.5G"
      volumeSpec:
        persistentVolumeClaim:
          resources:
            requests:
              storage: 4Gi
      arbiter:
        enabled: false
        size: 1
        affinity:
          antiAffinityTopologyKey: "kubernetes.io/hostname"

  sharding:
    enabled: true
    configsvrReplSet:
      size: 3
      affinity:
        antiAffinityTopologyKey: "kubernetes.io/hostname"
      podDisruptionBudget:
        maxUnavailable: 1
      expose:
        enabled: false
        exposeType: ClusterIP
      resources:
        limits:
          cpu: "300m"
          memory: "0.5G"
        requests:
          cpu: "300m"
          memory: "0.5G"
      volumeSpec:
        persistentVolumeClaim:
          resources:
            requests:
              storage: 4Gi

    mongos:
      size: 3
      affinity:
        antiAffinityTopologyKey: "kubernetes.io/hostname"
      podDisruptionBudget:
        maxUnavailable: 1
      resources:
        limits:
          cpu: "300m"
          memory: "0.5G"
        requests:
          cpu: "300m"
          memory: "0.5G"
      expose:
        exposeType: ClusterIP
      
  backup:
    enabled: true
    image: perconalab/percona-server-mongodb-operator:main-backup
    serviceAccountName: percona-server-mongodb-operator
    storages:
      minio:
        type: s3
        s3:
          bucket: psmdb-backups
          credentialsSecret: minio-secret
          endpointUrl: http://minio.minio.svc.cluster.local/mongodb/backups
          insecureSkipTLSVerify: false
          prefix: ""

    tasks:
      - name: backup
        enabled: true
        schedule: "*/5 * * * *"
        storageName: minio
        compressionType: gzip
        compressionLevel: 6
        keep: 3


    pitr:
      enabled: true
      oplogSpanMin: 10
      compressionType: gzip
      compressionLevel: 6

error log

create pbm object: create PBM connection to
    mongodb-rs0-1.mongodb-rs0.mongodb.svc.cluster.local:27017,mongodb-rs0-0.mongodb-rs0.mongodb.svc.cluster.local:27017,mongodb-rs0-2.mongodb-rs0.mongodb.svc.cluster.local:27017:
    create mongo connection to configsvr with connection string
    'mongodb://backup:kk3249@mongodb-cfg-0.mongodb-cfg.mongodb.svc.cluster.local:27017,mongodb-cfg-1.mongodb-cfg.mongodb.svc.cluster.local:27017,mongodb-cfg-2.mongodb-cfg.mongodb.svc.cluster.local:27017/?tls=true&tlsAllowInvalidCertificates=true&tlsCAFile=%2Ftmp%2Fmongodb-ca.crt&tlsCertificateKeyFile=%2Ftmp%2Fmongodb-tls.pem':
    mongo ping: server selection error: server selection timeout, current
    topology: { Type: Unknown, Servers: [{ Addr:
    mongodb-cfg-0.mongodb-cfg.mongodb.svc.cluster.local:27017, Type: Unknown,
    Last error: connection() error occured during connection handshake: x509:
    certificate is valid for localhost, mongodb-rs0, mongodb-rs0.mongodb,
    mongodb-rs0.mongodb.svc.cluster.local, *.mongodb-rs0, *.mongodb-rs0.mongodb,
    *.mongodb-rs0.mongodb.svc.cluster.local, not
    mongodb-cfg-0.mongodb-cfg.mongodb.svc.cluster.local }, { Addr:
    mongodb-cfg-1.mongodb-cfg.mongodb.svc.cluster.local:27017, Type: Unknown,
    Last error: connection() error occured during connection handshake: x509:
    certificate is valid for localhost, mongodb-rs0, mongodb-rs0.mongodb,
    mongodb-rs0.mongodb.svc.cluster.local, *.mongodb-rs0, *.mongodb-rs0.mongodb,
    *.mongodb-rs0.mongodb.svc.cluster.local, not
    mongodb-cfg-1.mongodb-cfg.mongodb.svc.cluster.local }, { Addr:
    mongodb-cfg-2.mongodb-cfg.mongodb.svc.cluster.local:27017, Type: Unknown,
    Last error: connection() error occured during connection handshake: dial tcp
    10.0.1.238:27017: i/o timeout }, ] }
  state: error

In aws eks, the cr.yaml file worked, but this error appears in a slow network environment. Is there any way to increase the ping check time?

1 Like