-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Replication
-
None
-
Environment:kubernetes cluster (k3s) installed in AWS ec2
image: mongo:4.4.4-bionic
-
ALL
TL DR
mongod --wiredTigerCacheSizeGB 0.25 --replSet rs0 --keyFile /data/db/security.keyFile ignored replSet param on initial run (means there no /data/db folder yet) in docker container, as running in js script rs.initiate() command showing following non-fatal error in mongod logs
```
MongoDB server version: 4.4.4
```
Also mongod logs showing following for cli params passed
```
Options set by command line","attr":{"options":{"net":{"bindIp":"127.0.0.1","port":27017,"tls":{"mode":"disabled"}},"processManagement":{"fork":true,"pidFilePath":"/tmp/docker-entrypoint-temp-mongod.pid"},"security":{"keyFile":"/data/db/security.keyFile"},"storage":{"wiredTiger":{"engineConfig":
}},"systemLog":{"destination":"file","logAppend":true,"path":"/proc/1/fd/1"}}}}
```
Using following manifests:
```
apiVersion: v1
kind: Service
metadata:
name: mongo
labels:
app: mongo
spec:
ports:
- port: 27017
selector:
app: mongo
—
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongo
namespace: default
spec:
replicas: 1
revisionHistoryLimit: 1
strategy:
type: Recreate
selector:
matchLabels:
app: mongo
template:
metadata:
labels:
app: mongo
tier: base
spec:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: mongo
image: mongo:4.4.4-bionic
args:
- "--wiredTigerCacheSizeGB"
- "0.25"
- "--replSet"
- "rs0"
- "--keyFile"
- "/data/db/security.keyFile"
ports:
- containerPort: 27017
volumeMounts:
- name: data
mountPath: /data/db
- name: entrypoint
mountPath: /docker-entrypoint-initdb.d/
env:
- name: MONGO_INITDB_DATABASE
valueFrom:
configMapKeyRef:
key: MONGO_DB
name: envars
- name: MONGO_INITDB_ROOT_USERNAME
valueFrom:
secretKeyRef:
key: MONGO_USER
name: sealed-secrets
- name: MONGO_INITDB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
key: MONGO_PASS
name: sealed-secrets
volumes:
- name: data
hostPath:
path: /data/mongodata
type: DirectoryOrCreate
- name: entrypoint
secret:
secretName: mongo-init
```
mongo-init secret value is
#/bin/bash
sleep 10s
mongo -u ${MONGO_INITDB_ROOT_USERNAME} -p ${MONGO_INITDB_ROOT_PASSWORD} <<EOF
rs.initiate()
EOF
sleep 10s