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
- 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
- Connect to the database using
databaseAdmin_rs0_connectionStringSrv defined in test-databaseadmin-conn-str secret
Versions
- Kubernetes: 1.35.4
- Operator: 1.23.0
- Database: 8.3
Anything else?
Suggested Fix
Add following selector to the current set: app.kubernetes.io/component=mongod
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=mongodbapp.kubernetes.io/managed-by=percona-server-mongodb-operatorapp.kubernetes.io/name=percona-server-mongodbapp.kubernetes.io/part-of=percona-server-mongodbapp.kubernetes.io/replset=<REPLICATION_SET_NAME>These labels are shared by both the Percona Server pods and the Percona Search pods.
Steps to reproduce
databaseAdmin_rs0_connectionStringSrvdefined intest-databaseadmin-conn-strsecretVersions
Anything else?
Suggested Fix
Add following selector to the current set:
app.kubernetes.io/component=mongod