<p>I would like to set the mongodb wiredTigerCacheSize in my kubernetes deployment (linux).<br />
In docker I could simply define:</p>
<blockquote>
<p>docker run -d --name my-mongo mongo --wiredTigerCacheSizeGB 0.25</p>
</blockquote>
<p>but not in kubernetes...</p>
<p>I have the following deployment:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-mongo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-mongo-db
  template:
    metadata:
      labels:
        app: my-mongo-db
    spec:
      containers:
      - name: my-mongo-db
        image: mongo
        env:
        ports:
        - containerPort: 27017
</code></pre>
<p>so far I have tried (did not work):</p>
<pre><code>lifecycle:
      postStart:
        exec:
          command: [&quot;/bin/sh&quot;, &quot;-c&quot;, &quot;mongod --wiredTigerCacheSizeGB 0.25&quot;]
</code></pre>

<p>After a lot of reading (thanks to Minsky who pointed me in the right direction) I have found the following solution to work:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-mongo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-mongo-db
  template:
    metadata:
      labels:
        app: my-mongo-db
    spec:
      containers:
      - name: my-mongo-db
        image: mongo
        command: [&quot;docker-entrypoint.sh&quot;]
        args: [&quot;mongod&quot;, &quot;--wiredTigerCacheSizeGB&quot;, &quot;0.25&quot;]
        env:
        ports:
        - containerPort: 27017
</code></pre>
