Description:
For the following CR config, with custom runAsUser and runAsGroup:
replsets:
- containerSecurityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
name: rs0
podSecurityContext:
fsGroup: 10001
runAsGroup: 10001
runAsNonRoot: true
runAsUser: 10001
perconaservermongodbs CR status ends up in error:
status:
conditions:
- lastTransitionTime: "2025-05-28T11:29:21Z"
message: 'handleReplsetInit: no mongod containers in running state'
reason: ErrorReconcile
status: "True"
type: error
message: |
Error: handleReplsetInit: exec add admin user: command terminated with exit code 1 / Warning: Could not access file: EACCES: permission denied, mkdir '/.mongodb'
/ MongoServerError: not primary
ready: 0
replsets:
rs0:
ready: 0
size: 0
size: 0
state: error
Version:
Kubernetes v1.29.9+k3s1
Operator 1.19.1
Database 8
How do you run the MongoDB operator and replica sets in Kubernetes environments that do not allow running containers as root user/group?