-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
What did you do to encounter the bug?
Steps to reproduce the behavior:
- Install operator
- Deploy
MongoDBCommunitywith
apiVersion: mongodbcommunity.mongodb.com/v1
kind: MongoDBCommunity
metadata:
name: sample-mongodb
namespace: mas-test
annotations:
mongodb.com/v1.architecture: "static"
spec:
type: ReplicaSet
members: 1
arbiters: 0
version: "7.0.24"
featureCompatibilityVersion: "7.0"
statefulSet:
spec:
template:
spec:
containers:
- name: mongod
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 1000m
memory: 512Mi
- name: mongodb-agent
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 1000m
memory: 512Mi
initContainers:
- name: mongodb-agent-readinessprobe
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 1000m
memory: 512Mi
- name: mongod-posthook
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 1000m
memory: 512Mi
volumeClaimTemplates:
- metadata:
name: data-volume
spec:
resources:
requests:
storage: 1Gi
- metadata:
name: logs-volume
spec:
resources:
requests:
storage: 0Mi
security:
authentication:
modes: ["SCRAM"]
users:
- name: sample
db: SampleDB
scramCredentialsSecretName: sample
passwordSecretRef:
name: sample-mongodb
roles:
- name: dbOwner
db: SampleDB
agent:
logFile: /dev/stdout
---
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: sample-mongodb
namespace: mas-test
data:
password: c2FtcGxlNo pod is created due to missing ServiceAccount mongodb-kubernetes-appdb.
What did you expect?
ServiceAccount mongodb-kubernetes-appdb created and Pod starting up.
What happened instead?
StatefulSet keeps in progressing state and is never starting up.
Screenshots
kubectl describe sts sample-mongodb:
Name: sample-mongodb
Namespace: mas-test
CreationTimestamp: Thu, 02 Oct 2025 08:27:09 +0200
Selector: app=sample-mongodb-svc
Labels: <none>
Annotations: <none>
Replicas: 1 desired | 0 total
Update Strategy: RollingUpdate
Pods Status: 0 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
Labels: app=sample-mongodb-svc
Service Account: mongodb-kubernetes-appdb
Init Containers:
mongod-posthook:
Image: quay.io/mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook:1.0.9
Port: <none>
Host Port: <none>
Command:
cp
version-upgrade-hook
/hooks/version-upgrade
Limits:
cpu: 1
memory: 512Mi
Requests:
cpu: 100m
memory: 256Mi
Environment: <none>
Mounts:
/hooks from hooks (rw)
mongodb-agent-readinessprobe:
Image: quay.io/mongodb/mongodb-kubernetes-readinessprobe:1.0.22
Port: <none>
Host Port: <none>
Command:
cp
/probes/readinessprobe
/opt/scripts/readinessprobe
Limits:
cpu: 1
memory: 512Mi
Requests:
cpu: 100m
memory: 128Mi
Environment: <none>
Mounts:
/opt/scripts from agent-scripts (rw)
Containers:
mongod:
Image: quay.io/mongodb/mongodb-community-server:7.0.24-ubi9
Port: <none>
Host Port: <none>
Command:
/bin/sh
-c
if [ -e "/hooks/version-upgrade" ]; then
#run post-start hook to handle version changes (if exists)
/hooks/version-upgrade
fi
# wait for config and keyfile to be created by the agent
echo "Waiting for config and keyfile files to be created by the agent..."
while ! [ -f /data/automation-mongod.conf -a -f /var/lib/mongodb-mms-automation/authentication/keyfile ]; do
sleep 3;
echo "Waiting..."
done
# sleep is important after agent issues shutdown command
# k8s restarts the mongod container too quickly for the agent to realize mongod is down
echo "Sleeping for 15s..."
sleep 15
# start mongod with this configuration
echo "Starting mongod..."
exec mongod -f /data/automation-mongod.conf
Args:
Limits:
cpu: 1
memory: 512Mi
Requests:
cpu: 100m
memory: 256Mi
Environment:
AGENT_STATUS_FILEPATH: /healthstatus/agent-health-status.json
Mounts:
/data from data-volume (rw)
/healthstatus from healthstatus (rw)
/hooks from hooks (rw)
/tmp from tmp (rw)
/var/lib/mongodb-mms-automation/authentication from sample-mongodb-keyfile (rw)
/var/log/mongodb-mms-automation from logs-volume (rw)
mongodb-agent:
Image: quay.io/mongodb/mongodb-agent:108.0.2.8729-1
Port: <none>
Host Port: <none>
Command:
/bin/bash
-c
current_uid=$(id -u)
declare -r current_uid
if ! grep -q "${current_uid}" /etc/passwd ; then
sed -e "s/^mongodb:/builder:/" /etc/passwd > /tmp/passwd
echo "mongodb:x:$(id -u):$(id -g):,,,:/:/bin/bash" >> /tmp/passwd
export NSS_WRAPPER_PASSWD=/tmp/passwd
export LD_PRELOAD=libnss_wrapper.so
export NSS_WRAPPER_GROUP=/etc/group
fi
agent/mongodb-agent -healthCheckFilePath=/var/log/mongodb-mms-automation/healthstatus/agent-health-status.json -serveStatusPort=5000 -cluster=/var/lib/automation/config/cluster-config.json -skipMongoStart -noDaemonize -useLocalMongoDbTools -logLevel INFO
Limits:
cpu: 1
memory: 512Mi
Requests:
cpu: 100m
memory: 128Mi
Readiness: exec [/opt/scripts/readinessprobe] delay=5s timeout=1s period=10s #success=1 #failure=40
Environment:
AGENT_STATUS_FILEPATH: /var/log/mongodb-mms-automation/healthstatus/agent-health-status.json
AUTOMATION_CONFIG_MAP: sample-mongodb-config
HEADLESS_AGENT: true
POD_NAMESPACE: (v1:metadata.namespace)
Mounts:
/data from data-volume (rw)
/opt/scripts from agent-scripts (rw)
/tmp from tmp (rw)
/var/lib/automation/config from automation-config (ro)
/var/lib/mongodb-mms-automation/authentication from sample-mongodb-keyfile (rw)
/var/log/mongodb-mms-automation from logs-volume (rw)
/var/log/mongodb-mms-automation/healthstatus from healthstatus (rw)
Volumes:
agent-scripts:
Type: EmptyDir (a temporary directory that shares a pod's lifetime)
Medium:
SizeLimit: <unset>
automation-config:
Type: Secret (a volume populated by a Secret)
SecretName: sample-mongodb-config
Optional: false
healthstatus:
Type: EmptyDir (a temporary directory that shares a pod's lifetime)
Medium:
SizeLimit: <unset>
hooks:
Type: EmptyDir (a temporary directory that shares a pod's lifetime)
Medium:
SizeLimit: <unset>
sample-mongodb-keyfile:
Type: EmptyDir (a temporary directory that shares a pod's lifetime)
Medium:
SizeLimit: <unset>
tmp:
Type: EmptyDir (a temporary directory that shares a pod's lifetime)
Medium:
SizeLimit: <unset>
Node-Selectors: <none>
Tolerations: <none>
Volume Claims:
Name: data-volume
StorageClass:
Labels: <none>
Annotations: <none>
Capacity: 1Gi
Access Modes: [ReadWriteOnce]
Name: logs-volume
StorageClass:
Labels: <none>
Annotations: <none>
Capacity: 0
Access Modes: [ReadWriteOnce]
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedCreate 22s (x15 over 104s) statefulset-controller create Pod sample-mongodb-0 in StatefulSet sample-mongodb failed error: pods "sample-mongodb-0" is forbidden: error looking up service account mas-test/mongodb-kubernetes-appdb: serviceaccount "mongodb-kubernetes-appdb" not found
Operator Information
- Operator Version:
1.4.0 - MongoDB Image used:
quay.io/mongodb/mongodb-community-server:7.0.24-ubi9(same with-ubi8)
Kubernetes Cluster Information
- Distribution:
RKE2 - Version:
1.32.9 - Image Registry location (quay, or an internal registry):
quay
Additional context
Operator was deployed with Helm Chart mongodb/mongodb-kubernetes using following values:
operator:
replicas: 1
mdbDefaultArchitecture: static
managedSecurityContext: false
watchNamespace: "*"
vaultSecretBackend:
enabled: false
telemetry:
enabled: false
collection:
frequency: 720h
send:
frequency: 720h
registry:
pullPolicy: IfNotPresent
community:
mongodb:
imageType: ubi9
resource:
tls:
enabled: falseDue to enforced restricted security policy i had to patch the operator with
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongodb-kubernetes-operator
namespace: mongodb-operator
spec:
template:
spec:
securityContext:
runAsNonRoot: true
runAsUser: 2000
runAsGroup: 2000
fsGroup: 2000
fsGroupChangePolicy: "OnRootMismatch"
seccompProfile:
type: "RuntimeDefault"
volumes:
- name: tmp
emptyDir:
medium: Memory
containers:
- name: mongodb-kubernetes-operator
securityContext:
privileged: false
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
volumeMounts:
- name: tmp
mountPath: /tmpIf possible, please include:
- The operator logs
- Below we assume that your replicaset database pods are named
mongo-<>. For instance:
❯ k get pods
NAME READY STATUS RESTARTS AGE
❯ k get mdbc
NAME PHASE VERSION
NAMESPACE NAME PHASE VERSION
mas-test sample-mongodb Pending
yardenshoham
Metadata
Metadata
Assignees
Labels
No labels