Skip to content

MongoDB Server Service includes Percona Search in it's selector #2515

Description

@mansur-abdirimov

Report

When deploying a MongoDB cluster using the PerconaServerMongoDB CRD with Percona Search enabled, the Kubernetes Service created for accessing the MongoDB cluster includes Percona Search pods in its selector. As a result, the Service endpoints contain both MongoDB database pods and Percona Search pods, which in turn breaks clients connecting through a mongodb+srv:// connection string.

More about the problem

The Service currently uses the following selector set:

  • app.kubernetes.io/instance=mongodb
  • app.kubernetes.io/managed-by=percona-server-mongodb-operator
  • app.kubernetes.io/name=percona-server-mongodb
  • app.kubernetes.io/part-of=percona-server-mongodb
  • app.kubernetes.io/replset=<REPLICATION_SET_NAME>

These labels are shared by both the Percona Server pods and the Percona Search pods.

Steps to reproduce

  1. Deploy PerconaServerMongoDB resource with following configuration:
apiVersion: psmdb.percona.com/v1
kind: PerconaServerMongoDB
metadata:
  name: test
  finalizers:
    - percona.com/delete-psmdb-pvc
spec:
  image: perconalab/percona-server-mongodb:8.3
  search:
    enabled: true
    image: perconalab/percona-search-mongodb:1.70.1
    size: 1
    storage:
      persistentVolumeClaim:
        resources:
          requests:
            storage: 10Gi
    resources:
      requests:
        cpu: "2"
        memory: 2Gi
  replsets:
    - name: rs0
      size: 1
      affinity:
        antiAffinityTopologyKey: none
      resources:
        limits:
          cpu: "500m"
          memory: 1G
        requests:
          cpu: "100m"
          memory: 100Mi
      volumeSpec:
        persistentVolumeClaim:
          resources:
            requests:
              storage: 3Gi
      podSecurityContext:
        runAsUser: 1001
        runAsGroup: 1001
        supplementalGroups:
          - 1001
        fsGroup: 1001
        fsGroupChangePolicy: OnRootMismatch      
  unsafeFlags:
    replsetSize: true  
  1. Connect to the database using databaseAdmin_rs0_connectionStringSrv defined in test-databaseadmin-conn-str secret

Versions

  1. Kubernetes: 1.35.4
  2. Operator: 1.23.0
  3. Database: 8.3

Anything else?

Suggested Fix
Add following selector to the current set: app.kubernetes.io/component=mongod

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions