Kubernetes Killing Mongo Container Kubernetes Killing Mongo Container docker docker

Kubernetes Killing Mongo Container


Based on what Stennie from MongoDB, Inc. wrote in comment to question.

this command in kube .yaml works for me:

      command:        - "sh"        - "-c"        - >          echo "storage:" >>  /etc/mongod.conf;          echo "    wiredTiger:" >>  /etc/mongod.conf;          echo "       engineConfig:" >>  /etc/mongod.conf;          echo "          cacheSizeGB: 2" >>  /etc/mongod.conf;          echo "replication:" >> /etc/mongod.conf;          echo "  replSetName: YOUR_REPL_NAME" >> /etc/mongod.conf;          mongod --config /etc/mongod.conf;

also there is a way to set it in runtime:

db.adminCommand( { "setParameter": 1, "wiredTigerEngineRuntimeConfig":"cache_size=2G"})

which also works just fine, but it looks easier through kuberneties yaml file because to issue a command you have to wait until mongo is up and running.

NOTE:make sure that your:

      resources:        limits:          memory:

is allowing extra 1G for system.